Archive | AI/ML RSS feed for this section

Machine Learning and Deep Learning Basics

10 Sep

1. Introduction

    Artificial Intelligence is a broad field, but most of its modern breakthroughs stem from Machine Learning (ML) and its subfield Deep Learning (DL).

      • Machine Learning focuses on algorithms that learn patterns from data and improve with experience.

      Deep Learning is a specialized subset of ML that uses neural networks with many layers to process large, complex data like images, speech, and text.

      2. Concepts & Explanations

      Machine Learning Paradigms

      Machine Learning (ML) is a core subfield of Artificial Intelligence that enables systems to learn from data and improve over time without being explicitly programmed for every task. In ML, models identify patterns and make decisions based on training data.

      Machine learning is the scientific study of algorithms and statistical models that computer systems use to effectively perform a specific task without using explicit instructions, relying on patterns and inference instead.

      Building a model by learning the patterns of historical data with some relationship between data to make a data-driven prediction

      General Architecture of Machine Learning: 

      Business understanding: Understand the given use case, and also, it’s good to know more about the domain for which the use cases are built.

      Data Acquisition and Understanding: Data gathering from different sources and understanding the data. Cleaning the data, handling the missing data if any, data wrangling, and EDA( Exploratory data analysis).

      Modeling: Feature Engineering – scaling the data, feature selection – not all features are important. We
      use the backward elimination method, correlation factors, PCA and domain knowledge to select the
      features.
      Model Training based on trial and error method or by experience, we select the algorithm and train with
      the selected features.
      Model evaluation Accuracy of the model , confusion matrix and cross-validation.
      If accuracy is not high, to achieve higher accuracy, we tune the model…either by changing the algorithm
      used or by feature selection or by gathering more data, etc.
      Deployment – Once the model has good accuracy, we deploy the model either in the cloud or Rasberry
      Pi or any other place. Once we deploy, we monitor the performance of the model. if its good…we go live
      with the model or reiterate the all process until our model performance is good.
      It’s not done yet!!!
      What if, after a few days, our model performs badly because of new data. In that case, we do all the
      process again by collecting new data and redeploy the model.

      ML can be classified into 3 main paradigms:

      Supervised Learning : Here the machine learns from  labeled data.

      Learn from labeled data (input + output).

      Example: Predicting house prices from square footage.

      Algorithms: Linear regression, decision trees, support vector machines.

      In supervised learning, the model is trained on a labeled dataset — where each input is paired with the correct output. The goal is to learn a mapping from inputs to outputs, enabling the model to make accurate predictions on new, unseen data.

      Supervised learning is classified into two categories of algorithms:
      Classification: A classification problem is when the output variable is a category, such as “Red” or “blue”, “disease” or “no disease”.
      Regression: A regression problem is when the output variable is a real value, such as     “dollars” or “weight”.

      Examples:

      •  Predicting house prices (input: size, location; output: price)
      • Email spam detection (input: email content; output: spam/not spam)
      •  Image classification (input: image pixels; output: object label)

      Common Algorithms:

      • Linear Regression
      • Logistic Regression
      • Decision Trees
      • Support Vector Machines (SVM)
      • Neural Networks

      Use Cases:
                              1. Fraud detection
                              2. Sentiment analysis
                              3. Medical diagnosis

      1. Unsupervised Learning
        • Learn from unlabeled data, finding patterns and structure.
        • Example: Grouping customers into segments based on shopping behavior.
        • Algorithms: K-means clustering, PCA (Principal Component Analysis).

      In unsupervised learning, the model is given input data without labels. The goal is to find hidden patterns, groupings, or structures within the data.

      An unsupervised model, in contrast, provides unlabelled data that the algorithm tries to make sense of by extracting features, co-occurrence and underlying patterns on its own.

      Examples:

      •  Clustering users based on browsing behavior
      •  Dimensionality reduction for data visualization
      •   Anomaly detection in network traffic

      Common Algorithms:

      • K-Means Clustering
      • Hierarchical Clustering
      • Principal Component Analysis (PCA)
      • Autoencoders

      Use Cases:

      • Market segmentation
      • Recommender systems
      • Data compression

      Reinforcement Learning (RL)

      An agent learns by interacting with an environment, receiving rewards or penalties.

      Example: Training a robot to walk, or AI to play chess.

      Reinforcement Learning (RL) is a goal-directed learning paradigm in which an agent learns to make decisions by interacting with an environment. It receives feedback in the form of rewards or penalties based on its actions and aims to maximize cumulative reward over time.

      Reinforcement learning is less supervised and depends on the learning agent in determining the output solutions by arriving at different possible ways to achieve the best possible solution.

      Examples:

      Teaching a robot to walk,

      Training an AI to play chess or Go

      Optimizing delivery routes

      Key Concepts:

      Agent: The learner or decision-maker

      Environment: Everything the agent interacts with

      Reward Signal: Feedback for good or bad behavior

      Policy: The strategy the agent uses to make decisions

      Use Cases:

      • Game AI
      • Robotics control
      • Dynamic pricing
      • Personalized recommendations

      💡 Analogy:

      • Supervised → A teacher provides answers to all practice problems.
      • Unsupervised → A student tries to find patterns in problems without answers.
      • Semi-supervised → Some answers are given, the rest must be figured out.

      Reinforcement → Learning by trial and error, like a baby learning to walk.

      Traditional ML vs. Deep Learning

      • Traditional ML
        • Relies on hand-crafted features (e.g., edge detectors in images).
        • Works well for small-to-medium datasets.
        • Examples: Decision Trees, Random Forests, SVMs.
      • Deep Learning
        • Learn features automatically from raw data using neural networks.
        • Requires large datasets and high computational power.
        • Excels in complex tasks (e.g., speech recognition, image generation).

      📘 Diagram (text description):

      • Traditional ML pipeline: Raw Data → Feature Engineering → Model Training → Prediction.
      • Deep Learning pipeline: Raw Data → Neural Network (learns features + model) → Prediction.

      2.3 Neural Networks: Architecture & Learning

      A neural network is inspired by the human brain:

      • Neurons → simple units that take input, apply a function, and pass output.
      • Layers
        • Input layer (data features).
        • Hidden layers (transformations).
        • Output layer (prediction/classification).

      💡 Analogy: Imagine a bakery:

      • Input layer → Ingredients.
      • Hidden layers → Baking process (mixing, heating, decorating).
      • Output layer → Final cake.

      2.4 Core Concepts

      • Activation Functions: Decide how much signal passes through a neuron.
        • Examples: Sigmoid, ReLU, Tanh.
      • Loss Function: Measures how far predictions are from true values.
        • Example: Mean Squared Error for regression, Cross-Entropy Loss for classification.
      • Optimizers: Algorithms that adjust model parameters to minimize loss.
        • Example: Gradient Descent, Adam optimizer.
      • Backpropagation: The process of propagating errors backward through the network to update weights.

      2.5 Evaluation Metrics

      Different tasks require different evaluation metrics:

      • Classification: Accuracy, Precision, Recall, F1-score.
      • Regression: Mean Squared Error (MSE), R² score.
      • Generative models (later chapters): BLEU score, Perplexity, Fréchet Inception Distance (FID).

      2.6 Bias, Fairness & Ethics

      AI models can inherit bias from data:

      • Example: A recruitment model trained on biased data may unfairly reject female candidates.
      • Fairness techniques: Data balancing, bias detection, and fairness-aware algorithms.
      • Ethics: Transparency, accountability, and ensuring AI benefits society.

      3. Use Cases & Applications

      • Healthcare: Predict disease risks, detect cancer from medical scans.
      • Finance: Credit scoring, fraud detection.
      • Education: Personalized learning systems.
      • Retail: Customer segmentation, demand forecasting.
      • Transportation: Autonomous driving using deep learning for object detection.

      4. Algorithms & Techniques

      Let’s explore two practical ML approaches:

      4.1 Supervised Learning Example (Classification)

      # Classifying iris flowers using scikit-learn

      from sklearn.datasets import load_iris

      from sklearn.model_selection import train_test_split

      from sklearn.tree import DecisionTreeClassifier

      from sklearn.metrics import accuracy_score

      # Load dataset

      iris = load_iris()

      X, y = iris.data, iris.target

      # Split into train and test sets

      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)

      # Train decision tree

      clf = DecisionTreeClassifier()

      clf.fit(X_train, y_train)

      # Predictions

      y_pred = clf.predict(X_test)

      print(“Accuracy:”, accuracy_score(y_test, y_pred))

      4.2 Deep Learning Example (Neural Network for Digit Recognition)

      import tensorflow as tf

      from tensorflow.keras.datasets import mnist

      from tensorflow.keras.models import Sequential

      from tensorflow.keras.layers import Dense, Flatten

      from tensorflow.keras.utils import to_categorical

      # Load dataset

      (X_train, y_train), (X_test, y_test) = mnist.load_data()

      X_train, X_test = X_train / 255.0, X_test / 255.0  # normalize

      y_train, y_test = to_categorical(y_train), to_categorical(y_test)

      # Build neural network

      model = Sequential([

          Flatten(input_shape=(28, 28)),

          Dense(128, activation=’relu’),

          Dense(10, activation=’softmax’)

      ])

      # Compile and train

      model.compile(optimizer=’adam’, loss=’categorical_crossentropy’, metrics=[‘accuracy’])

      model.fit(X_train, y_train, epochs=5, validation_data=(X_test, y_test))

      # Evaluate

      loss, accuracy = model.evaluate(X_test, y_test)

      print(“Test Accuracy:”, accuracy)


      5. Case Study / Mini-Project

      Mini-Project: Spam Email Classifier

      We’ll build a simple spam detection model using Naive Bayes.

      from sklearn.model_selection import train_test_split

      from sklearn.feature_extraction.text import CountVectorizer

      from sklearn.naive_bayes import MultinomialNB

      from sklearn.metrics import classification_report

      # Example dataset

      emails = [“Win money now!!!”, “Meeting at 3 pm”, “Get cheap loans instantly”, “Lunch tomorrow?”]

      labels = [1, 0, 1, 0]  # 1 = spam, 0 = not spam

      # Vectorize text

      vectorizer = CountVectorizer()

      X = vectorizer.fit_transform(emails)

      # Train-test split

      X_train, X_test, y_train, y_test = train_test_split(X, labels, test_size=0.25, random_state=42)

      # Train Naive Bayes classifier

      clf = MultinomialNB()

      clf.fit(X_train, y_train)

      # Predictions

      y_pred = clf.predict(X_test)

      print(classification_report(y_test, y_pred))

      ➡️ This shows how supervised learning can classify emails as spam or not spam.


      6. Summary

      We explored practical examples: iris classification, digit recognition, and spam detection.
      Machine Learning enables computers to learn patterns from data.

      Main paradigms: supervised, unsupervised, semi-supervised, reinforcement learning.
      Traditional ML relies on feature engineering; Deep Learning learns features automatically.
      Key concepts: activation functions, loss functions, optimizers, and backpropagation.
      Evaluation metrics help measure model performance.
      Ethical challenges (bias, fairness) must be addressed.

      ➡️ (Above content is taken by my best selling book Generative AI & Machine Learning)


      Fast API Project Structure

      14 Aug

      FastAPI project structure that incorporates multiple design patterns including:

      • Dependency Injection
      • Repository Pattern
      • Service Layer
      • Strategy Pattern
      • Factory Pattern
      • Observer Pattern
      • Builder Pattern
      • Domain-Driven Design (DDD) principles

      🧱 Project Structure

      fastapi_project/
      │
      ├── app/
      │   ├── main.py                  # FastAPI app entry point
      │   ├── config.py                # App configuration
      │   ├── dependencies/            # DI providers
      │   │   ├── db.py
      │   │   ├── auth.py
      │   │   └── __init__.py
      │   │
      │   ├── models/                  # Pydantic models
      │   │   ├── user.py
      │   │   ├── request.py
      │   │   └── __init__.py
      │   │
      │   ├── domain/                  # Domain models (DDD)
      │   │   ├── entities/
      │   │   │   ├── user_entity.py
      │   │   │   └── __init__.py
      │   │   └── __init__.py
      │   │
      │   ├── repositories/            # Repository pattern
      │   │   ├── user_repository.py
      │   │   └── __init__.py
      │   │
      │   ├── services/                # Business logic (Service Layer)
      │   │   ├── user_service.py
      │   │   └── __init__.py
      │   │
      │   ├── strategies/              # Strategy pattern
      │   │   ├── auth/
      │   │   │   ├── jwt_strategy.py
      │   │   │   ├── oauth_strategy.py
      │   │   │   └── __init__.py
      │   │   └── __init__.py
      │   │
      │   ├── factories/               # Factory pattern
      │   │   ├── service_factory.py
      │   │   └── __init__.py
      │   │
      │   ├── observers/               # Observer pattern
      │   │   ├── event_manager.py
      │   │   └── __init__.py
      │   │
      │   ├── builders/                # Builder pattern
      │   │   ├── report_builder.py
      │   │   └── __init__.py
      │   │
      │   ├── middleware/              # Custom middleware
      │   │   ├── logging_middleware.py
      │   │   └── __init__.py
      │   │
      │   ├── routes/                  # API routes
      │   │   ├── user_routes.py
      │   │   └── __init__.py
      │   │
      │   └── utils/                   # Utility functions
      │       ├── helpers.py
      │       └── __init__.py
      │
      ├── requirements.txt
      └── README.md
      
      

      🧩 How Patterns Fit Together

      PatternFolderPurpose
      Dependency Injectiondependencies/Inject DB, auth, config
      Repositoryrepositories/Abstract DB access
      Service Layerservices/Business logic
      Strategystrategies/Pluggable auth or processing logic
      Factoryfactories/Create services based on config
      Observerobservers/Event-driven notifications
      Builderbuilders/Construct complex objects
      DDDdomain/Domain entities and aggregates

      Conclusion: In a FastAPI project, you can implement several software design patterns to improve modularity, scalability, and maintainability. Here’s a categorized overview of the most relevant patterns and how they apply to FastAPI

      Understanding the Evolution: Generative AI, AI Agents, and Agentic AI

      12 Aug

      Introduction

      As artificial intelligence continues to evolve, it’s essential to distinguish between three foundational yet distinct paradigms: Generative AI, AI Agents, and Agentic AI. While these concepts are closely related, each represents a different level of autonomy, complexity, and capability. This guide breaks down their core differences, practical applications, and how they build upon one another.

       


      1. Generative AI: Creating Content on Demand

      What It Is

      Generative AI refers to models—like large language models (LLMs) and image generators—that produce original content based on patterns learned from massive datasets. These models are trained on diverse data (text, images, audio, video) and contain billions of parameters.

      How It Works

      Generative AI is reactive: it responds to user prompts without initiating actions or managing tasks. For example, when prompted to “write a poem about data science,” the model generates a poem but doesn’t decide to write one on its own.

      Key Features

      • Trained on large, multimodal datasets

      • Generates text, images, audio, or video

      • Requires prompt engineering to guide output

      • Examples: OpenAI’s GPT-4, Meta’s LLaMA 3

      • Supported by tools like LangChain, LlamaIndex, and Grok


      2. AI Agents: Task-Oriented Intelligence

      What They Are

      AI agents extend generative AI by adding autonomy and interactivity. They can perform specific tasks by integrating with external tools and APIs, making them more dynamic and useful in real-world applications.

      Why They Matter

      LLMs alone can’t access real-time or private data. AI agents solve this by making tool calls—requests to external systems—to fetch current or specialized information.

      Example Workflow

      1. User asks a question.

      2. Agent checks if the LLM can answer.

      3. If not, it calls an external API (e.g., for today’s news).

      4. It processes the response.

      5. It delivers a final answer to the user.

      Key Features

      • Built on LLMs with external tool integration

      • Can retrieve real-time or private data

      • Perform single, well-defined tasks

      • Still reactive, but with enhanced capabilities

      • Act autonomously within defined boundaries


      3. Agentic AI: Orchestrating Complex Workflows

      What It Is

      Agentic AI represents the next level—multi-agent systems that collaborate to complete complex, multi-step workflows. Each agent specializes in a subtask, and together they operate like a coordinated team.

      Use Case: YouTube to Blog

      An agentic AI system might:

      1. Extract a transcript from a YouTube video

      2. Generate a blog title

      3. Write a summary and description

      4. Compose a conclusion

      Each step is handled by a different agent, and outputs are passed between them to produce a polished blog post.

      Key Features

      • Multiple agents working in sequence or parallel

      • Each agent handles a specific subtask

      • Enables end-to-end automation of complex workflows

      • Supports human feedback for refinement

      • Adds adaptability and robustness through collaboration


      4. Comparative Summary

      Minimize image
      Edit image
      Delete image


      5. Strategic Implications

      Generative AI

      Ideal for creative content generation, but limited by its reactive nature. Success depends heavily on prompt quality.

      AI Agents

      Bridge the gap between static models and dynamic applications. Useful in domains like customer service, analytics, and decision support.

      Agentic AI

      Best suited for automating complex, multi-step processes. Aligns with real-world workflows and supports scalability, adaptability, and human oversight.


      Conclusion

      Understanding the distinctions between generative AI, AI agents, and agentic AI is essential for anyone working with modern AI systems. From content creation to autonomous task execution and workflow orchestration, these paradigms represent a clear evolution in capability and complexity. By choosing the right approach, organizations can unlock new levels of efficiency, creativity, and intelligence in their AI-driven solutions.

      Understanding Generative AI: Key Concepts and Use Cases

      10 Aug

      Generative AI is like a magic artist. It learns from a lot of examples and then uses that learning to create new things that fit the patterns it learned. It’s like having a creative computer friend that can make up new music, art, or even stories!

      Generative AI (GenAI) is a type of artificial intelligence that is used to generate new data or content from existing data. It can be used to create new text, images, videos, and other forms of data.

      Large Language Models are a type of generative AI that use deep learning algorithms to generate natural language from large datasets. They are used for a variety of applications such as natural language processing, machine translation, and question answering.

      Large Language Modal (LLM) Use Cases

      Large Language Models (LLMs) like GPT-4 have a wide range of use cases across various industries and domains. Here are some prominent use cases:

      1. Content Generation:
        • Writing articles, blog posts, and reports.
        • Creating marketing copy and advertising content.
        • Drafting emails and messages.
      2. Conversational Agents:
        • Developing chatbots and virtual assistants.
        • Enabling natural language interactions in customer support.
      3. Language Translation:
        • Translating text between different languages.
        • Facilitating real-time language translation for travelers and businesses.
      4. Text Summarization:
        • Summarizing lengthy documents, research papers, and articles.
        • Generating concise overviews for news stories.
      5. Code Generation:
        • Writing code snippets in various programming languages.
        • Assisting developers in automating repetitive tasks.
      6. Creative Writing:
        • Crafting poetry, stories, and screenplays.
        • Generating unique content for artistic purposes.
      7. Educational Tools:
        • Providing explanations and answers for students’ questions.
        • Offering tutoring and learning assistance.
      8. Data Analysis:
        • Assisting in data interpretation and insights generation.
        • Simplifying complex statistical information for non-experts.
      9. Medical and Scientific Applications:
        • Analyzing medical records and generating clinical reports.
        • Assisting researchers in data analysis and hypothesis generation.
      10. Legal and Compliance:
        • Drafting legal documents, contracts, and agreements.
        • Offering legal research and analysis support.
      11. Personal Assistants:
        • Managing calendars and scheduling appointments.
        • Sending reminders and setting alarms.
      12. Gaming and Entertainment:
        • Generating in-game dialogues and narratives.
        • Creating interactive storytelling experiences.
      13. Accessibility Support:
        • Assisting individuals with disabilities in communication and information access.
      14. Market Research and Analysis:
        • Extracting insights from social media and online discussions.
        • Analyzing consumer sentiment and trends.
      15. Simulations and Training:
        • Simulating characters and scenarios for training purposes.
        • Enhancing virtual reality experiences.
      16. Human Resources:
        • Assisting in resume writing and job description creation.
        • Conducting initial candidate screenings.
      17. Innovative Interfaces:
        • Enabling voice-controlled applications and devices.
        • Powering interactive storytelling experiences.
      18. Knowledge Management:
        • Assisting in documentation, note-taking, and knowledge retrieval.
        • Organizing and summarizing research materials.
      19. Automated Social Media:
        • Generating social media posts and engagement.
        • Providing suggestions for content creation.
      20. Ethical and Societal Debates:
        • Engaging in philosophical discussions and debates on ethical issues.
        • Promoting critical thinking and diverse perspectives.

      These are just a few examples of the diverse applications of Large Language Models. As the technology evolves, new use cases will likely continue to emerge.

      What is a Foundation Model?

      foundation model is a large-scale language model trained on vast amounts of data and designed to perform a wide range of tasks. These models are evaluated using diverse prompts across many scenarios, enabling them to generalize effectively and adapt to various downstream applications such as text generation, summarization, translation, and more.

      Key Characteristics of GPT-4 Foundation Model

      1. Scale and Architecture

      GPT-4 is built using a Mixture of Experts (MoE) architecture, comprising 1.76 trillion parameters across 120 layers  This is more than 10 times the size of GPT-3. The model routes inputs through a subset of 2 out of 16 expert networks per forward pass, optimizing performance and cost.

      2. Training Data

      GPT-4 was trained on approximately 13 trillion tokens, sourced from a mix of datasets including CommonCrawlRefinedWeb, and other curated sources. It also includes data from platforms like TwitterRedditYouTube, and a large collection of textbooks and code repositories 

      3. Generative Capabilities

      GPT-4 is a generative model, capable of producing original, contextually relevant content. It can:

      • Write essays and articles
      • Generate computer code
      • Create charts and websites from text descriptions
      • Compose emails, summaries, and more

      4. Human-like Interaction

      GPT-4 maintains context across interactions, remembering previous prompts and adapting to new inputs. This enables natural, conversational exchanges, similar to human dialogue.

      5. Adaptability

      Through continuous interaction, GPT-4 learns patterns and relationships, improving its responses over time. This adaptability reduces the need for retraining for each new task.

      6. Self-supervised Learning

      GPT-4 uses self-supervised learning, allowing it to train on unlabeled data. This approach enables the use of massive raw datasets, shifting the focus from manual labeling to computational scalability.

      7. Multi-modal Learning

      GPT-4 supports multi-modal inputs, including text and images, enabling it to interpret and generate content across different data types. This mimics human-like sensory learning and expands its utility.

      8. Few-shot and Zero-shot Learning

      GPT-4 excels at few-shot and zero-shot learning, allowing it to perform tasks with minimal or no specific training examples. This makes it highly versatile and efficient for rapid deployment.

      What are Prompts?

      Generative AI models primarily interact with users through text-based input. You provide instructions or requests via a text interface, and the model works to fulfill them. In general, this input is called a prompt.

      For large language models (LLMs) like GPT-4 or ChatGPT, prompts can range from straightforward questions (e.g., “Who is the president of the India?”) to complex tasks (e.g., “Analyze the impact of globalization on the development of third-world countries, focusing on economic, political, and social aspects.”). Prompts may also include various forms of data—even files such as CSVs—or be as casual and open-ended as “Tell me a joke. I’m feeling down today.”

      What is Prompt Engineering?

      Prompt Engineering is a relatively new field focused on creating and refining prompts to make the most effective use of language models (LMs) across various applications and research areas. Developing these skills helps users understand both the strengths and limitations of large language models (LLMs).

      It is applied by:

      • AI professionals – converting tasks into prompt-based datasets that a model can be trained on.
      • Researchers – enhancing LLM performance on a range of tasks from question answering to arithmetic reasoning.
      • Developers – designing reliable prompting techniques to connect LLMs with other tools.

      Types of Writing Prompts

      1. Instruction – Directly tells the model what to do.
        Example: “Write a story about a poor, hardworking farmer who becomes a successful businessman through determination.”
      2. Continuation – Provides a partial sentence or text for the model to complete.
        Example:
        Prompt: “The following is a step-by-step process for preparing chicken salad. Step 1: Cut the veggies –”
        AI Response: “Step 2: Toss the chicken nuggets. Step 3: Mix everything together.”
      3. In-Context Learning (ICL) – Supplies a few examples in the prompt, enabling the model to learn from them and apply the same logic to new inputs.
        Example: Providing short passages with labeled topics so the AI can classify a new passage correctly.

      Delimiters in Prompts

      A delimiter is a symbol or marker used to separate sections within a prompt. It:

      • Organizes information for clarity.
      • Marks where tasks or sections begin and end.
      • Helps the AI focus on specific parts of the prompt.
      • Often works with a stop sequence (e.g., \n, ###, ===, ::).

      Benefits of Delimiters

      • Improved Control – Focus the model on the right section of text.
      • Multi-Turn Conversations – Separate user inputs from AI responses for coherent dialogues.
      • Task Separation – Divide multiple tasks (e.g., summarization, translation) within one prompt.
      • Context Preservation – Maintain conversation flow in interactive sessions.
      • Simultaneous Prompts – Handle multiple requests in one input for batch responses.
      • Customization – Use custom delimiter tokens to suit specific needs.
        Example:
        Task1: Summarize === “Healthy ecosystems require a variety of species…”
        Task2: Translate === “Hello, how are you?”
        Here, === clearly separates tasks so the AI can respond to each one independently.

      Elements Of Prompts

      A prompt can include several components, but not all are always necessary. The structure and combination of these elements should be tailored to the specific task or objective.

      prompt_component

      Key processes in prompt engineering

      There are three main processes to follow in prompt engineering:

      Types Of Prompts

      1. Open Ended Prompts: An Open-ended prompt requires the model to generate an answer with few constraints or options given by the prompt.

      2. Closed Type: A Closed-ended prompt asks the model to complete an action on a text, given specific parameters and instructions.

      Prompt TypeDescriptionExample
      RewriteModify the existing content to suit different variations such as form, tone, persona, etc.Infuse a cheerful tone into this blog.
      ExtractExtract a specific block of text verbatim from the given content.Identify the sentence where the doctor recommended the treatment plan.
      SummarizeInvolves summarizing a block of text while avoiding the use of exact wording from the original text.Summarize the key tasks from this conference report.
      Closed ended QAThis entails extracting information from a written text, which can be either extractive or abstractive in nature.How frequently did Alice discuss her new project in this conversation?
      Close ended classificationRequesting the model to categorize a given text based on a provided selection of classes.Categorize the content as either Travel, Fashion, or Entertainment.

      Designing prompts for different tasks

      A prompt can contain information like the instruction or question you are passing to the model and include other details such as inputs or examples. Today’s LLMs can perform all kinds of advanced tasks that range from text summarization, mathematical reasoning, to code generation. Well-crafted prompts can be used to perform all types of interesting and different tasks.

      Note: This is just very beginning introduction of GenAI. To complete content and knowledge you may DM me on er.sandeepp@gmail.com directly or you may join my live sessions for the same.

      You may join my WhatsApp group for further notification about boot camp : https://chat.whatsapp.com/JTnI8LL9FgrI4G8Qcm68fq