0% found this document useful (0 votes)
3 views515 pages

API Mid Merged

Uploaded by

ngosocialwork073
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views515 pages

API Mid Merged

Uploaded by

ngosocialwork073
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

API-driven Cloud

Native Solutions
BITS Pilani Dr. Shreyas Rao
Pilani Campus Associate Prof. (Off Campus), CSIS, BITS-Pilani
BITS Pilani
Pilani Campus

Course Name - API-driven Cloud Native Solutions


Course Number - CC ZG506 / SE ZG506
Units - 5
Instructor Profile
Dr. Shreyas Rao
•22 Years of Experience in IT, Teaching and Research

•Working as Associate Professor (Off Campus), Dept. of CSIS, BITS-Pilani, WILP

•B.E from VTU, M.S in Software Systems from BITS (WILP) and PhD from MAHE

•Worked as Business Analyst and Team Lead at SLK Software Services for 7+
years

•Previously worked in Presidency University and Sahyadri College, Mangaluru as


R&D Head, CSE

•Executed 10+ Consultancy projects

•COE member in AI&ML and COE member in Data Science (Govt. Sponsored for
1.2 Cr)

BITS Pilani, Pilani Campus


Instructor Profile

Consultancy
•ISRO-SAC (Ahmedabad) funded research project titled “Ontology Enabled
Disaster Management Web Service using Data Integration” as Technical
Consultant. Deployed in ISRO.

Collaboration with Dept. of Health Innovation, Kasturba Hospital, MAHE

•Telemedicine effectiveness during Covid Wave-I at Kasturba Hospital, Manipal

•Study on psychological implications of COVID-19 on Nursing professionals

•Covid prediction using Patient Discharge Data

*Published papers can be viewed at [Link]

BITS Pilani, Pilani Campus


Instructor Profile
Application Development
•Design and Development of AI enabled tool for juvenile self-transformation
(Mental Health domain, App Development, Deep Learning & NLP) for Dept. of
Psychology, Montfort College.
•SEEC application for MAHE University (Applied patent)
•Grievance Management Portal
•Designed and Developed ‘Dhriti’, a mental health resource Chabot that caters to
mental health needs of people during Covid, from the COE in AI&ML, SCEM. Bot is
released in Dakshina Kannada region of Karnataka which answers user queries in
English, Kannada and Hindi languages. Deployed on the Web and Facebook
Messenger channels, used by 5000+ users.

BITS Pilani, Pilani Campus


Instructor Profile

Courses I teach at BITS

•API-Driven Cloud Native Solutions

•Design of Conversational Experiences

•Scalable Services

•DevOps for Cloud

•Introduction to Data Science

•Software Engineering

•Introduction to DevOps

•Web Technologies

•Software Architecture

BITS Pilani, Pilani Campus


Student Profile

• Name

• Role in Organization (Ex: Developer, Tester, Architect etc.)

• Years of Experience

• Exposure to Cloud Native development? Yes / No (If yes, mention Cloud name)

• Exposure to API-based development? Yes / No

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Walkthrough of Course Handout


Course Description

Analyze, Design, Develop and Deploy cloud native applications in innovative areas
such as Data Science, Artificial Intelligence/Machine Learning (AI/ML), IoT, Data
Analytics etc.; Build an end to end complex application; Extensive usage of well-
known PaaS/APIs; Demonstration of compliance with relevant, industry adapted
best practices; Deployment using modern strategies; Presentation of the
Milestones and outcomes in appropriate forms; Periodic review of progress of the
project by faculty.

BITS Pilani, Pilani Campus


Course Objectives
No Objective

CO1 Explain the fundamentals of APIs, including RESTful and GraphQL APIs, and
demonstrate how to design, specify, and implement API versioning

CO2 Identify the key components of the cloud-native ecosystem such as DevOps,
microservices, containers, and serverless computing

CO3 Apply APIs and relevant tools to execute end-to-end data science and machine learning
projects

CO4 Design AI assistants using APIs for use cases in natural language processing, speech
recognition, and computer vision, and construct generative AI assistants using the RAG
approach based on suitable language models

CO5 Develop and deploy end-to-end IoT and data analytics projects using APIs, serverless
functions, and containers

BITS Pilani, Pilani Campus


Module Structure

Module Description

0 Python Programming [Self-Study]


1 API Basics
2 Cloud Native Application

3 Data Science and Machine Learning

4 AI and Cognitive Services


Part A: Basic APIs for AI applications
Part B: Language Models
Part C: Cloud Native Application Deployment
5 IoT and Data Analytics

BITS Pilani, Pilani Campus


Contact Session wise Coverage

Session Coverage
CS01 API Basics (OpenAPI, REST, gRPC, GraphQL)
CS02 API Basics + Cloud Native Application
CS03 Cloud Native Application
CS04 Introduction to Data Science & Machine Learning and Lifecycles
CS05 API driven Cloud-native Data Pipeline
CS06 API-driven ML pipelines
CS07 Tools review; Case Study
CS08 Basic APIs for AI Applications – NLP, CV, Speech recognition
CS09 Language Models (LLMs)
CS10 RAG Models
CS11 RAG Models
CS12 Cloud Native Application Deployment
CS13 IoT and Data Analytics
CS14 APIs for IoT and Data Analytics
CS15 Serverless Functions; Case study
CS16 Course review and discussion

BITS Pilani, Pilani Campus


Experiential Learning

Lab. No Module Session Experiment Tools list (Indicative only)


No. No.
Demonstrate the design and development of API- Prefect, AirFlow
based data pipeline which involves data ingestion,
1 3 5 pre-processing, analysis and monitoring activities

Demonstrate the design and development of AWS SageMaker, MLFlow


3 Machine Learning pipeline which involves model
2 7 development, training, deployment and monitoring
activities

Demonstrate NLP tasks such as speech processing, HuggingFace APIs and / or


language translation, text summarization, and text AWS APIs or
3 4 8
generation using Cloud-based APIs OpenAI APIs

Demonstrate a generative AI assistant, using RAG [Link]


approach, which answers queries about an LangChain
4 4 11 application (chatbot) OpenAI APIs
Python code to invoke APIs

Demonstrate API-based IoT and Data Analytics OpenRemote


5 5 14 or 15 application ThingsBoard

BITS Pilani, Pilani Campus


Evaluation

Evaluation Name Type Weight Duration


Component

EC – 1 Quiz I Online 5%

Lab Assignment I Online 15%


[Mini Project I]

Lab Assignment II Online 15%


[Mini Project II]

EC – 2 Mid-term Exam Closed 30% 2 hours


book

EC – 3 End Semester Open book 35% 2.5 hours


Exam

BITS Pilani, Pilani Campus


Information!

1. All the sessions will be conducted on MS Teams, in online mode.


2. EC-1 components (Assignments) will be administered on the Taxila portal.
3. All the Course Material (Handout, PPTs etc.) will be uploaded on MS Teams.
4. Announcements will be made on Taxila portal when,
Assignment(s) are administered
Rescheduling or Cancellation of class (if any)
To notify the Syllabus for Mid-Sem and Comprehensive exams
To upload the Scheme and Solution documents for Mid-sem and Comprehensive exams.
5. Email for correspondence – [Link]@[Link]
[Request - Mention the course code / course name in the subject line]

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Lecture No. 1
Agenda

API Basics
Introduction to APIs
HTTP APIs
OpenAPI Specification
REST, GraphQL and gRPC based APIs
API Versioning, Semantic versioning
Examples of API - Google Maps API, Rapid API, Conference API etc.

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

API
API
• Acronym for “Application Programming Interface”

• Some definitions

1. API is a contract between a service and its clients

2. Set of rules and protocols for building and interacting with software applications. The
application will be exposed as set of APIs [API-first approach]

3. APIs enable different software systems to communicate with each other, allowing for
data exchange and functional integration without requiring the end-user to understand
the underlying code.

BITS Pilani, Pilani Campus


Synchronous vs Asynchronous

• Synchronous execution means the


first task in a program must finish
processing before moving on to
executing the next task [blocked]
• Asynchronous execution means a
second task can begin executing in
parallel, without waiting for an
earlier task to finish [non-blocked]

BITS Pilani, Pilani Campus


Synchronous APIs

• A synchronous API is one where each request must wait for the previous
one to complete before the next one can start.

Ex: REST, gRPC, GraphQL

Fig. Order service invokes other services using REST APIs

BITS Pilani, Pilani Campus


Asynchronous APIs

• In contrast, an asynchronous API allows multiple operations to be initiated


and potentially completed concurrently, without waiting for each operation to
finish before starting the next one.

Ex: Message Brokers like RabbitMQ, Apache Kafka, SQS etc.

Fig. Client and Order service invokes other services using message brokers

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

HTTP APIs
HTTP APIs

• HTTP (Hypertext Transfer Protocol) APIs are a standard way for applications
to communicate over the web.

• Use HTTP Protocol

• Define a set of rules and conventions for sending and receiving requests and
responses between clients (such as web browsers or mobile apps) and
servers.

• Typically seen in “Browser -> Server” communication

BITS Pilani, Pilani Campus


Components of HTTP API

1. API Endpoints

2. API Request

3. API Response

BITS Pilani, Pilani Campus


API Endpoints

• The API endpoints are simple URLs that represent the collection of objects
or a single object.

• The resources are found usually on the server, the API endpoints are used
to send the request to resources.

• Each endpoint is a URL designed to perform a single function by accessing


the required resources.

• Endpoints act as the “doors” or “paths” through which a client application


can send HTTP requests to the API server.

BITS Pilani, Pilani Campus


API Request
• Client (Browser or Mobile) sends HTTP Request to a specific API endpoint

• Purpose is to request data or perform a specific operation

• Every API request begins with selecting appropriate HTTP method (or verb)

HTTP Methods / Verbs

GET: To retrieve data

POST: To submit data to the server

PUT: To update existing data

DELETE: To delete data

Ex: Facebook or Youtube

BITS Pilani, Pilani Campus


API Response

• Refers to the data or information sent back by the API server after
processing a request.

• Formats: JSON / XML


200 OK: The request was successful, and the
server is returning the requested data.
201 Created: The request has resulted in creating
a new resource on the server.
400 Bad request: The client’s request is malformed
or contains errors.
401 Unauthorized: Authentication credentials are
missing or invalid.
403 Forbidden: The client is not allowed to access
the requested resource.
404 Not found: The requested resource does not
exist.
500 Internal server error: An unexpected server
error occurred.

BITS Pilani, Pilani Campus


Try it!

• Open your terminal

> curl -X GET "[Link]

HTTP Request - GET

HTTP Endpoint - [Link]

HTTP Response – Posts in JSON format

• Try with Fiddler application / Postman

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Open API Specification

[Link]
What is OpenAPI

• API Description Standard

• The OpenAPI Specifications [previously Swagger specification] provides a


formal standard for describing HTTP APIs, mainly RESTful APIs.

• This allows people to understand how an API works, how a sequence of APIs
work together, generate client code, create tests, apply design standards etc.

BITS Pilani, Pilani Campus


What is OpenAPI

Framework, Server,
Storage, Cloud etc.

BITS Pilani, Pilani Campus


Bookstore Scenario

• Let's go through the entire process


with a practical example of building a
HTTP API for an online bookstore
using Python and FastAPI.

BITS Pilani, Pilani Campus


1. Requirements

• The API should allow users to manage books [CRUD operations]


• add a new book

• retrieve book details

• update book information

• delete books

BITS Pilani, Pilani Campus


2. Design

Identify the API Endpoints Sample Data Model for “book”


{
•GET /books
"id": integer,
•POST /books "title": "string",
"author": "string",
•GET /books/{id} "isbn": "string",
"publishedDate": "string",
•PUT /books/{id}
"price": integer
•DELETE /books/{id} }

BITS Pilani, Pilani Campus


3. Configure and 4. Publish

Configure / Identify:

•FastAPI framework in Python for development

•Uvicorn as the Web Server

•JSON for storing the Book details

Publish the API

•Documentation is auto-generated by FastAPI and available at /docs

•URL - Localhost:8000/docs

BITS Pilani, Pilani Campus


5. Develop 6. Test 7. Deploy

Develop

•Implement the API using FastAPI.

•Implement all HTTP methods for GET, POST, PUT and DELETE

Test

•Use “pytest” or “unittest” frameworks for testing

Deploy

•Various platforms such as Heroku, AWS, Google Cloud can be used

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

REST
REST
• Architectural Style, Architecture of the Web. [Roy Fielding in 2000]
• REST Architecture treats every content as a resource
• Each resource identified by a URI (Uniform Resource Identifier)
• Ex: Web pages, Image, Video, PDF, Dynamic business data etc.
• Resource representation formats – JSON / XML
• HTTP methods for CRUD (create, read, update, delete) operations on
resources:
– GET: Retrieve representation of resource
– POST: Create a new resource
– PUT: Update/modify existing resource
– DELETE: Delete an existing resource
* Suitable permissions are required for POST / PUT / DELETE operations

BITS Pilani, Pilani Campus


REST
XML format
<user>
<id>1</id>
<name>Shreyas</name>
<profession>Teacher</profession>
</user>

JSON format
{
"id“ : 1,
"name“ : “Shreyas",
"profession“ : "Teacher"
}

BITS Pilani, Pilani Campus


REST ARCHITECTURE

BITS Pilani, Pilani Campus


REST - Examples
HTTP Method URI Operation

GET [Link] For fetching information for all students

GET [Link] For fetching the student having ID 123


123
POST [Link] Submit the student information

PUT [Link] Update the student information for student with


123 ID 123
DELETE [Link] Delete the student with ID 123
123

Sample curl commands


curl -X GET [Link]
curl -X GET "[Link]

Guidelines for REST API design - [Link]


examples/

BITS Pilani, Pilani Campus


RESTful API based Application
[Food Delivery App]

BITS Pilani, Pilani Campus


REST – Benefits and
Drawbacks
Benefits
•Mature and ubiquitous – de facto standard for APIs
•Testing a REST API is simple
•Supports synchronous request-response communication
•No intermediate broker
•Supported by most programming languages / frameworks

Drawbacks
•Reduced availability
•Fetching multiple resources [fetching a user’s profile, their posts, and comments
might require three separate API calls.]

BITS Pilani, Pilani Campus


Why RESTful APIs are important for this course?

Most AI services from AWS, Azure, or GCP support RESTFul APIs


Ex: Amazon Bedrock is a tool to build generative AI apps with foundation models

Sample APIs from Amazon Bedrock


List models
Endpoint: [Link]
[Pass request with access tokens, and response in JSON]

Model Inference
Endpoint: [Link]
[Pass request with access tokens, and response in JSON]

* Same is true for HuggingFace, LangChain, Prefect which support RESTful APIs

BITS Pilani, Pilani Campus


Demo

Demo of the Bookstore application using RESTful APIs

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

GraphQL
REST

Scenario - Fetch user profile, user posts and comments on the posts from a Social
Media Application

REST Drawback - Fetching multiple resources requires multiple HTTP requests

REST
1. Fetch user profile - GET /users/{userId}
2. Fetch user posts - GET /users/{userId}/posts
3. Fetch comments on posts – GET /posts/{postId}/comments

BITS Pilani, Pilani Campus


GraphQL

To overcome drawbacks of REST


Facebook in 2015 came up with new API Syntax – GraphQL
As an alternative to REST, GraphQL is a versatile query language, that lets
developers construct requests that pull data from multiple data sources in a
single API call. [Connect to multiple endpoints or databases]
Single request and all-inclusive reply
Uses ‘query’ operation to fetch data
Uses ‘mutation’ operations to insert, update, or delete data.

[Link]

BITS Pilani, Pilani Campus


GraphQL

GraphQL Server receives client request (HTTP Post), and does following activities.
[Link] to Schema Definition: Before it starts processing requests, the server defines a
schema using GraphQL Schema Definition Language (SDL). This schema specifies the
types of data that can be queried by the clients and the relationships between different data
types. It acts as a blueprint that both the server and client understand.
[Link], Execution, and Response Formation: When a request is made, the server first
validates this request against the pre-defined schema to ensure it only asks for data that the
schema supports. The server then executes this request on the /graphql endpoint, interacting
with the necessary databases or data sources to gather the requested data. Finally, it forms
a response in JSON format, which is sent back to the client.

BITS Pilani, Pilani Campus


GraphQL

BITS Pilani, Pilani Campus


GraphQL
Data in JSON format
{
GraphQL Query "data": {
"books": [
query { {
"title": "To Kill a Mockingbird",
books {
"author": "Harper Lee",
title "publishedDate": "July 11, 1960"
author },
publishedDate {
"title": "1984",
} "author": "George Orwell",
} "publishedDate": "June 8, 1949"
Sample Data Model for “book” },
{ {
"id": integer, "title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"title": "string", "publishedDate": "April 10, 1925"
"author": "string", }
"isbn": "string", ]
"publishedDate": "string", }
}
"price": integer
}
BITS Pilani, Pilani Campus
REST vs GraphQL - Example

Scenario - Fetch user profile, user posts and comments on the posts from a
Social Media Application

GraphQL
REST query {
1. Fetch user profile - GET /users/{userId} user(id: "123") {
2. Fetch user posts - GET /users/{userId}/posts id
3. Fetch comments on posts – name
GET /posts/{postId}/comments posts {
id
title
comments {
id
content
}
}
}
}

BITS Pilani, Pilani Campus


Real Example - AWS

[Link]

BITS Pilani, Pilani Campus


Option 1: Fully managed AWS Service
(AppSync)

*AppSync is a managed GraphQL server that coordinates front end requests


with backend services
[Link]
BITS Pilani, Pilani Campus
Option 2: Self-Managed GraphQL

[Link]

BITS Pilani, Pilani Campus


Demo - GraphQL
Show a GraphQL Query Demo using Strawberry GraphQL Library in Python
using the code first approach

Some terms in the code


@[Link]: A decorator used to define GraphQL types that map to
Python classes.
@[Link] -> Method should be exposed as a field in the GraphQL
schema. This means that the method can be queried directly by a GraphQL
client.

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

gRPC
RPC
Remote Procedure Call (RPC) is a communication between client and remote server
Used for distributed, client-server applications

BITS Pilani, Pilani Campus


RPC
Client Node and Client Stub: The client node
makes a procedure call, which is handled by the
client stub. The stub packages the call into a
message and sends it over the network.
Network: The network facilitates the transmission
of messages between the client and server stubs.
Server Stub and Server Node: The server stub
receives the message, unpacks it, and passes the
call to the server node. The server node processes
the request and returns the result back through the
server stub, which then sends it back over the
network to the client stub.
Client Node: Finally, the client stub receives the
response, unpacks it, and delivers it to the client
node.

BITS Pilani, Pilani Campus


gRPC
Initially created by Google in 2015
gRPC is a robust open-source RPC framework to build scalable APIs
Protocol Buffers are used for data exchange, instead of JSON
Uses HTTP/2 as the protocol [Instead of HTTP]
‘Protoc’ is the compiler
Supports 10+ languages – C#.NET, C++, Dart, Go, Java, Kotlin, Node,
Objective-C, PHP, Python, Ruby

BITS Pilani, Pilani Campus


gRPC

BITS Pilani, Pilani Campus


gRPC proto file [API
definition]
• Once we have defined gRPC proto file,
we can use the “protobuf compiler –
protoc” to generate code in our
preferred programming language.
• This generated code includes the
classes and methods needed to create
and parse the messages defined in the
proto file, as well as client and server
stubs that can be used to call the
methods defined in the file.
• By using gRPC proto, we can define our
API in a language- and platform-neutral
way, and then generate code for
multiple programming languages.

BITS Pilani, Pilani Campus


gRPC proto file for Calculator
syntax = "proto3";

package calculator;

service Calculator {
rpc Add (AddRequest) returns (AddResponse) {}
rpc Multiply (MultiplyRequest) returns (MultiplyResponse) {}
}

message AddRequest {
int a = 1;
int b = 2;
}

message AddResponse {
int result = 1;
}

message MultiplyRequest {
double a = 1;
double b = 2;
}

message MultipleResponse {
double result = 1;
}

BITS Pilani, Pilani Campus


gRPC Demo

Proto file -> “[Link]”


Server logic implemented in Python listens on a port.
Client logic implemented in Python sends requests to server, and gets
response of the calculator functionality.

Ref URL - [Link] for Python

BITS Pilani, Pilani Campus


gRPC Advantages and
Disadvantages

Advantages
•It has simple, well-defined service interfaces and schema
•It is polyglot (supports multiple languages)
•Lightweight and Fast API
•Best for Inter-Service Communication

Disadvantages
•It may not be suitable for external-facing services
•The support for gRPC in browser and mobile applications is still in the primitive
stages [grpc-Web extension is available for limited browsers]

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Comparison
Comparison

Feature Best API Type


Ubiquitous standard for Web REST
Data Fetch GraphQL
Browser Support REST / GraphQL

Request Caching REST


Code Generation gRPC - Native support for 10+ languages
GraphQL - GraphQL Code Generator [3RD party]
REST – Swagger [3rd party]
Payload data structure GraphQL - JSON
REST - JSON & XML
gRPC - Protocol Buffers

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

API Versioning
API Versioning

• API versioning is the practice of managing changes to an API and ensuring


that these changes are made without disrupting clients.

• A good API versioning strategy clearly communicates the changes made


and allows API consumers to decide when to upgrade to the latest version at
their own pace.

• Why it is important?

When a third-party application developer uses your API to build an integration,


they expect that the API will be stable. If you make changes to your API
without considering clients, it forces them to change their own software.
Otherwise, their applications could break if updates aren’t accounted for.
[Link]
versioning#:~:text=What%20is%20API%20versioning%3F,version%20at%20their%20own%20pace.

BITS Pilani, Pilani Campus


API Versioning
When to version API?

•Costly (Cost and Effort) for API Consumers and Developers

•Best to consider in case of breaking change – change in API that causes client applications to fail

Breaking changes are:

•Changing the format of request or response data (like switching from JSON format to XML format)

•Changing the data type of a resource (like changing from a string to an integer)

•Changing the name of a resource

•Removing one or more resources, removing or changing properties or methods for a particular
resource, or any other changes to API functionality

•Adding a new required field for client HTTP requests.

[Link]
versioning#:~:text=What%20is%20API%20versioning%3F,version%20at%20their%20own%20pace.

BITS Pilani, Pilani Campus


API - Semantic Versioning

• Semantic Versioning is a versioning scheme for using meaningful version numbers.

• A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-
negative integers, and MUST NOT contain leading zeroes.

• X is the major version, Y is the minor version, and Z is the patch version. Each
element MUST increase numerically.

• Ex: 1.9.0; 2.11.1

Google Maps JavaScript API – Current Version is 3.63.10a (13-January-2026)

URL - [Link]

3.63 is the major/minor version series.


10 is the patch version within that series.
a/d/b/etc. are sub-patch identifiers to represent minor updates, bug-fix builds

BITS Pilani, Pilani Campus


API - Semantic Versioning

• Major version: In this approach, your URI would denote the breaking
changes to the API. A new major version requires creating a new API. The
version number is what you use to route to the correct host via your URI.
Indicates incompatible API changes.

• Minor version: You update change logs to inform API consumers of new
functionality or bug fixes. It introduces a non-breaking functionality.
• Patch versions: A patch is an update which is meant to fix existing bugs and
it's backward compatible. It introduces non-breaking functionality.

BITS Pilani, Pilani Campus


Semantic Versioning - Example

Example – API Versioning for Movies


Version 1.0.0: This is the initial release of the API. It provides basic information about movies, such
as the title, director, release year, and plot summary.
Version 1.1.0: This version adds some new features to the API. For example, it may allow users to
search for movies based on specific criteria, such as genre or actor.
Version 1.1.1: This is a patch release that fixes some bugs in the 1.1.0 version of the API. It doesn't
introduce any new features.
Version 2.0.0: This is a major release that introduces significant changes to the API. For example, it
may switch to a new data format or add new endpoints for accessing movie data. The new version
may not be backward compatible with the previous version, so clients will need to update their code
to work with the new API.
Version 2.1.0: This version adds some new features to the 2.0.0 version of the API, but still
maintains backward compatibility with the previous version.
Version 2.1.1: This is a patch release that fixes some bugs in the 2.1.0 version of the API. It doesn't
introduce any new features

BITS Pilani, Pilani Campus


Semantic Versioning - Example

Each version of the API would be accessible through a specific endpoint, such
as:
/api/v1.0.0/movies: Endpoint for accessing basic movie information in version
1.0.0 of the API.
/api/v1.1.0/movies/search: Endpoint for searching movies based on specific
criteria in version 1.1.0 of the API.
/api/v2.0.0/movies: Endpoint for accessing movie data in version 2.0.0 of the API.
/api/v2.1.0/movies/search: Endpoint for searching movies based on specific
criteria in version 2.1.0 of the API.

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

API Examples
[Self Study]
1. PetStore API
• Swagger Petstore - OpenAPI 3.0
• URL - [Link]
• Observe the JSON based API structure

BITS Pilani, Pilani Campus


2. Rapid API

• World’s largest public API Marketplace

• URL - [Link]

• Explore the APIs

BITS Pilani, Pilani Campus


3. Conference API

R2: “Mastering API Architecture – Design, Operate and Evolve API-Based


Systems”, by [Link] et al., O’Reilly, 2023

BITS Pilani, Pilani Campus


4. AsyncAPI Specification

URL - [Link]

Mainly used for “Event Driven Architectures”

BITS Pilani, Pilani Campus


Thank
You!
API-driven Cloud
Native Solutions
BITS Pilani Dr. Shreyas Rao
Pilani Campus Associate Prof. (Off Campus), CSIS, BITS-Pilani
BITS Pilani
Pilani Campus

CC ZG506 / SE ZG506
Lecture No. 2 and 3
Agenda

 Modern application requirements

 Cloud-native evolution

 Introducing Cloud-native software

 Cloud-enabled vs Cloud-based vs Cloud-native apps

 Examples for Cloud-native apps

 CNCF Landscape

 Overview of Cloud-native ecosystem


• Microservices and Service Mesh
• Serverless Computing and Serverless Stack
• DevOps and GitOps
• Containers and Kubernetes
 Case Study: Analysis of a cloud-native application architecture

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Case Study
Flipkart Big Billion Dollar Day
Sale

• Launched on 6-Oct-2014
• Opened at 8am
• Big discount in 70+ categories, flash sales, lucky draw
• Sold large units of Nokia Lumia 525, Samsung Galaxy Tabs
at throw-away prices
• Three Lakh order in 6 hours!

BITS Pilani, Pilani Campus


Flipkart Big Billion Dollar Day
Sale

Negatives:
•Website crashed due to huge traffic and footfalls
•Already selected products vanished from cart after recovery
or appeared as sold out!
•Money got deducted from account, but order not executed
•Big complaints from customers
•Reviews were hidden; no refund and no cancellation of
orders

From an Architecture perspective, what could have gone wrong?

BITS Pilani, Pilani Campus


Hotstar Case Study

What steps did the Hotstar Cloud Architects take to handle 25.3 Million
concurrent users?

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Modern Application Requirements

Ref: “Cloud Native Patterns”, by Cornelia Davis. Publisher: Manning, 2019


Modern Application Requirements

Streaming / OTT Social Media Apps

E-Commerce Apps Data Deluge (Infographic)

BITS Pilani, Pilani Campus


Modern Application Requirements

General Requirements Software Quality Attributes


 Scalability
[Link] Downtime
 Performance
[Link] Feedback Cycles  Availability
[Link] and Multi-device support  Reliability
[Link] driven  Interoperability
 Testability
 Usability
 Modifiability
 Security
 Portability
 Maintainability

BITS Pilani, Pilani Campus


Shift in the last 6-7 years

1. Shift from Monolith to Microservices Architecture


2. Shift from On-premise to Cloud (AWS, Azure, GCP) for hosting applications
3. Shift from Virtual Machine based deployment to Container based
deployment
4. Shift from Traditional CI/CD approaches (Monolith, Cloud-based or Cloud
enabled apps, VM based deployment) To Cloud-native CI/CD
[Microservices, Docker/ Kubernetes]

BITS Pilani, Pilani Campus


Evolution

Cloud Native App -> Agile + DevOps + Microservices + Containers + Cloud


[Link]

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Cloud-enabled vs Cloud-based vs Cloud-native


apps
Evolution of Cloud Native apps
Cloud Enabled

• Legacy applications

• Applications were built traditionally in a monolithic fashion

• They depend on local resources and hardware (on-premises)

• Integrate with services hosted on the cloud

• The application cannot take the advantage of factors like scalability as the
underlying architecture remains monolithic

• Ex: Mainframe applications

BITS Pilani, Pilani Campus


Cloud Enabled

Cloud Enabled

BITS Pilani, Pilani Campus


Cloud Based

• Applications moved to cloud to leverage capabilities of cloud

• Scalability

• Higher Availability

• No need of redesign of applications to migrate to cloud

• Ex: In-house web application moved to AWS or Azure

• Do not have to worry about

• Management of resources

• Maintaining the servers

• Backup

• Advantages

• Pay for what is used

• Scaling up/down

• Zero downtime

BITS Pilani, Pilani Campus


Cloud Native

• Redhat – “Cloud-native applications are a collection of small, independent, and


loosely coupled services.”

• VMWare – “Cloud native is an approach to building and running applications that


exploits the advantages of the cloud computing delivery model.”

• IBM – “Cloud native refers less to where an application resides and more to how it
is built and deployed.”

• Cloud-native is born in the cloud

• Cloud is about where we are computing; Cloud-native is about how

BITS Pilani, Pilani Campus


Cloud Native

• Cloud Native applications are:


• Architected to run in a Cloud environment (Public clouds – AWS, GCP, Azure)
• Built using cloud based technologies
• Accessible and Scalable

• Allow developers to continuously deliver new services more quickly and easily

• Cloud-native technologies
• Continuous integration
• Orchestrators
• Container engines

BITS Pilani, Pilani Campus


Cloud Native Technologies Pyramid

[Link]

BITS Pilani, Pilani Campus


Cloud Native – Focus Areas

• Design
• Cloud-native: Must think about failure. Use of microservices architecture. [Reliability]
• Cloud-based: Was designed for availability.

• Implementation
• Cloud-native: Faster to deploy because there is no hardware or software to
deploy.(Container Images)
• Cloud-based: Slower because of hardware provisioning or software setup.

• Pricing
• Cloud-native: Consumption-based-pricing (pay for what you use)

• Cloud-based: More expensive because you have to own the whole stack (compute –
EC2, storage, monitoring & logging services) etc.

BITS Pilani, Pilani Campus


Examples of Cloud Native
Applications

Netflix is a Airbnb is a well-known


Uber is another popular app that American vacation rental
famous streaming uses a cloud-native approach.
app for TV company that operates in
Uber has over 4,000 65,000 cities around the
shows, movies, independent microservices, world. As the company grew,
and which the team monitors using it shifted to a microservices
documentaries. the Prometheus platform. This model, and as of 2022, Airbnb
In 2016, the allows Uber developers to deploys 3,500 microservices
quickly respond to market per week, which allows the
organization
changes and update or scale a organization to keep providing
decided to go specific portion of the app.
cloud-native and services seamlessly to
thousands of customers.
shifted to
microservices.

BITS Pilani, Pilani Campus


CNCF - Cloud Native Computing Foundation

• CNCF is the open source, vendor-neutral hub for cloud native computing

• Part of Linux foundation

• URL - [Link]

• 24 Graduated projects (stable in production environment)

• ArgoCD, Kubernetes, envoy service proxy, Helm, Prometheus etc.

• 37 Incubating projects

• gRPC, Thanos (monitoring), OpenTelemetry (tracing) etc.

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Microservices
What is Monolithic Architecture?

• Monolith means composed all in one piece.


• They’re typically complex applications that
encompass several tightly coupled functions.
• When all functionality in a system had to be
deployed together, we consider it a monolith.

BITS Pilani, Pilani Campus


Monolith Application (Food
Delivery)

BITS Pilani, Pilani Campus


Monolithic Limitations

• Technology Barrier – embracing new technologies means application


needs to be re-written

• Scalability – The only option is scaling the whole application, since we


can’t scale the components independently

• Size – As application size increases, complexity increases, may


become unmanageable

• Difficult to understand – Every new joinee needs to understand the


entire application, not just his/her modules, because of dependencies
[Maintenance project problems]

BITS Pilani, Pilani Campus


What are Microservices

• An architectural style
• Microservices are autonomous, loosely
coupled, and independently deployable
services modeled around a business
domain
• Each microservice can focus on a
single business capability

Robert C. Martin’s Single Responsibility Principle


Gather together the things that change for the same reasons.
Separate those things that change for different reasons.

BITS Pilani, Pilani Campus


Why Microservices are required

Company Deployments

Amazon 23,000/ day

Google 5,500 / day

Netflix 500 / day

Twitter 3 / week

BITS Pilani, Pilani Campus


Example Architecture

BITS Pilani, Pilani Campus


Cloud – Microservices Market

BITS Pilani, Pilani Campus


Microservices Architecture (Food
Delivery)
API-First Design

BITS Pilani, Pilani Campus


CI/CD pipeline for Monolith vs
Microservices
Monolith
•Single Build Pipeline
•Bug fixing delays release of features
Microservice
•One service, one pipeline [pipeline-per-service pattern]
•High release velocity and reliability

[Link]

BITS Pilani, Pilani Campus


FTGO - Monolithic Hell - Pipeline

BITS Pilani, Pilani Campus


Microservices Pipeline – FTGO
Application

BITS Pilani, Pilani Campus


Recent shift back towards Monolith

• Amazon Prime Video Streaming Service has ditched its use of “microservices-
cum-serverless” model, reverting to a traditional, monolithic architecture.

• It vastly improved the workload’s cost and scalability.

• The team moved all the components into a single process, hosting them
on … EC2 and … ECS.

• Achieved a 90% reduction in operational costs

Ref
1. Article - [Link]
2. Architecture - [Link]
dump-microservices/
BITS Pilani, Pilani Campus
BITS Pilani
Pilani Campus

Serverless Computing
Some MCQs on Serverless

1. What is the main advantage of serverless computing?


A) Reduced manual server management
B) Enhanced data security
C) Increased physical infrastructure
D) Enhanced UI/UX design

2. Which of the following is NOT a component typically required to complete a serverless


stack on AWS?
A) Compute service
B) Database service
C) Virtual Machine service
D) HTTP Gateway service

3. What is the main role of AWS Lambda in a serverless stack?


A) It serves as a database service
B) It acts as the compute service
C) It manages HTTP requests
D) It handles networking

BITS Pilani, Pilani Campus


Some MCQs on Serverless

4. Which of the following is considered a drawback of serverless deployment?


A) High cost of operation
B) Vendor lock-in
C) Difficulty in scaling
D) Complex manual configuration

5. What happens during a 'cold start' in AWS Lambda?


A) The function runs instantly without any delay
B) A new container is created because there is no existing warm container
C) The function fails to execute
D) The function is triggered multiple times

BITS Pilani, Pilani Campus


Serverless Computing

Application deployment paradigm that allows applications to run on-demand,


consuming only the resources required to execute them
Build and run applications and services without managing infrastructure
Developers can focus on their core product
Ex: AWS Lambda, Google Cloud Functions (GCF), Azure Functions are examples
of FaaS (Function as a Service)

New Image upload Thumbnail or


medium-sized

BITS Pilani, Pilani Campus


Serverless Computing

BITS Pilani, Pilani Campus


AWS Serverless Services

BITS Pilani, Pilani Campus


AWS Lambda
(FaaS - Function as a Service)

BITS Pilani, Pilani Campus


Serverless Stack
When building Serverless applications, AWS Lambda is one of the main
candidates for running the application code. Typically, to complete a
Serverless stack you’ll need:

A Compute service;
A Database service; and
A HTTP Gateway service.
Lambda fills the primary role of the compute service on AWS.

It also integrates with many other AWS services and, together with API
Gateway, DynamoDB and RDS, forms the basis for Serverless solutions for
those using AWS.

Lambda supports many of the most popular languages and runtimes, so it’s a
good fit for a wide range of Serverless developers.

BITS Pilani, Pilani Campus


Demo of Serverless Application

Fiddler

AWS Lambda (Get and Post functions) are Serverless Compute


Amazon DynamoDB is the Serverless Database
Amazon API Gateway is the HTTP Gateway Service

BITS Pilani, Pilani Campus


Drawbacks of Serverless Deployment

It’s not the best scenario for executing long-running applications [No control over
the environment]
Vendor lock-in
Cold start [AWS Lambda typically keeps containers alive for 30-45 minutes. For a
new request, if a function is not running in a warmed container, a new container
will be created called ‘cold start’. Latency (more time) to execute the request]

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

DevOps
Need for DevOps

BITS Pilani, Pilani Campus


DevOps - Definition

1. DevOps is the process of alignment of IT Development and Maintenance


Operations with better and improved communication.

2. Microsoft defines DevOps as “Union of People, Process, and Products to enable


continuous delivery of value to the customers”
People -> Culture
Process -> DevOps Methodology
Products -> Tools

BITS Pilani, Pilani Campus


DevOps Dimensions

BITS Pilani, Pilani Campus


DevOps Process

BITS Pilani, Pilani Campus


CI/CD practices in DevOps

Continuous Integration, Continuous Delivery, Continuous Deployment (CI/CD)


are DevOps practices for producing software in short cycles between
merging source code changes and updating applications.
The ultimate goal of these practices is to:
Reduce the costs
Save time
Mitigate risks by delivering software in small pieces

BITS Pilani, Pilani Campus


CI/CD practices in DevOps

Automated

BITS Pilani, Pilani Campus


Continuous Integration (CI)

Continuous Integration is a software development practice in which developers


regularly commit and push their local changes back to the shared repository
(such as GIT, usually several times a day).
Before each commit, developers can run unit tests locally on their source code
as an additional check before integrating.
A continuous integration service automatically builds and runs unit tests on the
new source code changes to catch any errors immediately.

BITS Pilani, Pilani Campus


CI Workflow

BITS Pilani, Pilani Campus


Continuous Delivery (CD)

Source code changes are automatically prepared for deployment to a


production instance.
After a build, the build artifact with new changes is deployed to a staging
instance where advanced (integration, acceptance, load, end-to-end, etc.)
tests are run.
If needed, the build artifact is deployed to the production instance after manual
approval.

BITS Pilani, Pilani Campus


Continuous Deployment (CD)

Extends Continuous Delivery in which source code changes are automatically


deployed to a production instance.
The difference between Continuous Delivery and Continuous Deployment is the
presence of manual approval.
With Continuous Delivery, deployment to production occurs automatically after
manual approval.
With Continuous Deployment, deployment to production occurs automatically
without manual approval.

BITS Pilani, Pilani Campus


CI / CD Pipeline

A CI/CD pipeline is a series of steps that must be performed in order to deliver


a new version of software

[Link]

BITS Pilani, Pilani Campus


Team Formation

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

GitOps
GitOps

Term coined in 2017 in a series of Blogs by Alexis Richarson, cofounder


and CEO of Weaveworks.
Term is used in Cloud Native Community and Kubernetes Community
GitOps is a set of best practices and principles for managing
applications and infrastructure configurations using Git as the single
source of truth for declarative configuration and version control.
Developer-centric experience for managing applications with fully
automated pipelines or workflows.

BITS Pilani, Pilani Campus


What is GitOps and How it Works!

[Link]

[Duration – 10 minutes]

BITS Pilani, Pilani Campus


GitOps Definitions

Atlassian describes GitOps as “code-based infrastructure and operational


procedures that rely on Git as a source control system”

GitLab describes “an operational framework that takes DevOps best


practices used for application development such as version control,
collaboration, compliance, and CI/CD, and applies them to infrastructure
automation”

BITS Pilani, Pilani Campus


GitOps

Infrastructure as Code (IaC)

BITS Pilani, Pilani Campus


GitOps

BITS Pilani, Pilani Campus


GitOps Tooling

Tooling Type Example


Git code repository Git
Git management tool Bitbucket, GitHub, GitLab
Continuous integration tool CircleCI, Jenkins, Jenkinsx, GitHub Actions
Continuous delivery tool ArgoCD, FluxCD, Spinnaker
Container registry Docker Hub, AWS ECR, GHCR
Infrastructure provisioning AWS CloudFormation, Pulumi, Terraform,
AWS SAM
Configuration manager Ansible, Chef, Puppet, Helm charts (config
specific to Kubernetes)
Container orchestration Kubernetes, Nomad

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Containers
Docker / Kubernetes
Singer Analogy

A Singer is invited
A Singer forfor
is invited a a
01 concert.
concert. He
He goes
goes there
there and
and
MikeMike
doesdoes
not work
not work

Singer is invited to second


02 concert, where Speakers do
not work

Singer now invests in his own mike


03 and speakers, and takes them to
whichever concert he goes.

This way the vagaries of the environment


(mike, speaker) are avoided

BITS Pilani, Pilani Campus


What are Containers
A software container is a standardized package of software
Everything needed for the software to run is inside the container
The software code, runtime, system tools, system libraries, and settings are all
inside a single container
Container based deployments is favoured for Microservices

BITS Pilani, Pilani Campus


Docker
Is a popular Container technology
It is lightweight, portable and self-sufficient container

BITS Pilani, Pilani Campus


Docker - Container to Package Software

Dependencie
s

Application
Binarie Bundle
s

Code

BITS Pilani, Pilani Campus


Virtual Machines vs
Containers

BITS Pilani, Pilani Campus


Kubernetes / K8s

• Kubernetes is a container orchestration tool that manages applications/ services


available on a container platform like Docker

• Developed by Google labs and later donated to CNCF (Cloud Native Computing
Foundation)

• Open source

• Written in Golang

• Kubernetes manages the deployment, scaling, and operation of application containers.

BITS Pilani, Pilani Campus


Thank
You!
API-driven Cloud Native
Solutions
BITS Pilani Dr. Shreyas Rao
Associate Prof, Dept. of CSIS, BITS-Pilani
BITS Pilani

CC ZG506 / SE ZG506
Lecture No. 4
Contact Session wise Coverage
Session Coverage

CS01 API Basics (OpenAPI, REST, gRPC, GraphQL)


CS02 API Basics + Cloud Native Application Basics
CS03 Cloud Native Application
CS04 Introduction to Data Science & Machine Learning, DataOps & Data
MLOps Science
CS05 API driven Cloud-native Data Pipeline & ML
CS06 API-driven ML pipelines
CS07 Tools review; Case Study
CS08 Basic APIs for AI Applications – NLP, CV, Speech recognition
CS09 Language Models (LLMs)
Cognitive
CS10 RAG Models
AI
CS11 RAG Models
CS12 Cloud Native Application Deployment
CS13 IoT and Data Analytics
CS14 APIs for IoT and Data Analytics IoT
CS15 Serverless Functions; Case study
CS16 Course review and discussion
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Evaluation Components

Evaluation Name (Quiz, Lab, Type (Open Weight Duration Day, Date,
Component Project, Mid-term exam, book, Session, Time
End semester exam, etc.) Closed
book,
Online, etc.)
Quiz Online 5% 3 days March 1-10,
EC – 1*
2026
Project / Assignment Online 30% 40 days March-May,
2026
Mid-Semester Test Closed 30% 2 hours 14/03/2026
EC - 2
Book (EN)
Comprehensive Exam Open Book 35% 2½ 23/05/2026
EC - 3
Hours (EN)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Agenda

Session 4:
• Big Data and Characteristics
• Introduction to Data Science and Machine Learning
• Data Science Process

Session 5:
• DataOps
• Building an API driven Cloud-native Data Pipeline
[Practical Demo]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani

Data Story
BITS Pilani

Big Data
Data Deluge

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Big Data

• Big Data analytics deals with collection, storage,


processing, and analysis of this massive scale data

Analytics

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Characteristics of Big Data

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Characteristics of Big Data

1. Volume
• Volume of data involved is so large that it is difficult to
store, process and analyze data on a single machine
• Volumes of data generated by IT / IoT systems is growing
exponentially
• Lowering costs of data storage and processing
architectures [possible due to Cloud]
• Need to extract valuable insights from the data to
improve business processes, efficiency and service to
consumers

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Characteristics of Big Data

2. Velocity
• Velocity of data refers to how fast the data is generated
• High velocity of data results in the volume of data
accumulated to become very large, in short span of time
• Ex: High velocity data: real time data from Sensors, stock
market trades, social media streams
• Ex: Low velocity data: Census data, payroll processing

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Characteristics of Big Data

3. Variety
• Variety refers to the forms / types of the data
• Big data comes in different forms such as structured,
unstructured or semi-structured, including text data,
image, audio, video and sensor data
• Structured -> Relational DB, Excel spreadsheets
• Semi-structured -> JSON, XML, YAML
• Unstructured -> PDF, PPT, Video

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Characteristics of Big Data

4. Veracity
• Veracity refers to how accurate is the data. Need to
consider data provenance
• To extract value from the data, the data needs to be
cleaned to remove noise

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Characteristics of Big Data

5. Value
• Value of data refers to the usefulness of data for the
intended purpose
• The value of the data is also related to the veracity or
accuracy of the data
• For some applications value also depends on how fast
we are able to process the data
• Should the data be aggregated to be processed? [Ex: IoT
sensors capturing air pollutant parameters]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani

Data Science
Data Science [Some definitions]

• Data Science is the "study of data"


• Data Science is an art of uncovering insights and trends
that are hiding behind the data
• Data Science helps to translate data into a story. The
story telling helps in uncovering insights. The insights
help in making decision or strategic choices
• Involves all aspects of “Data” including data collection,
preprocessing, analysis, prediction, visualization
(storytelling) and gaining insights

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Data Science – Interdisciplinary Field

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Data Science, AI, and ML Convergence

[Link]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani

Roles in a Data Science project


Roles in Data Science Project [10 mins]

[Link]

[Link]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Key Takeaways - I

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Key Takeaways - II

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Key Takeaways - III

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Data Science – Hierarchy of Needs

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani

Data Science Process / Methodology


Data Science Process / Methodology

• The data science process (methodology) is a structured approach


used to extract valuable insights from data, typically involving a
series of iterative steps
• This process is widely adopted across industries to tackle complex
data-driven problems and build predictive models

Some popular Methodologies are:


• CRISP-DM (Cross Industry Standard Process for Data Mining)
• DASC-PM (Data Science – Process Model)
• Big Data Analytics Life Cycle for Data Science projects
• SEMMA (Sample, Explore, Modify, Model, Assess) applied for ML
projects

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Big Data Analytics Life Cycle

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study [IBM]

• Case: "Predicting Patient Survival After Cardiac Surgery


Using Classification Models”

• Process: Big Data Analytics Life Cycle

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study

Stage 1: Business Case Evaluation

• Objective: Define the business goal, which is to predict the survival


of patients within 30 days after cardiac surgery. This prediction helps
identify high-risk patients who may require additional care and
monitoring.

• Activities: Stakeholders such as cardiologists, surgeons, and


hospital administrators are involved in understanding the clinical and
operational benefits of the predictive model. The key performance
indicators (KPIs) could include reduction in post-operative mortality
rates and improved patient management.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study

Stage 2: Data Identification

• Objective: Identify the data sources needed for the analysis.

• Activities: The data sources include electronic health records


(EHRs) with patient demographics, pre-operative health data (e.g.,
blood pressure, cholesterol levels), intra-operative data (e.g., surgery
duration, anesthesia type), and post-operative data (e.g.,
complications, ICU stay). Additional data like patient history and
lifestyle factors may also be relevant.

• Role: Data Architect

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study

Stage 3: Data Acquisition and Filtering

• Objective: Gather and filter the data necessary for building the
predictive model.

• Activities: The required data is collected from the hospital’s EHR


system and other relevant databases. Filtering (at this stage is
optional) is performed to ensure data quality, such as removing
incomplete records or formatting all the date records into a particular
format.

• Role: Data Engineer

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study

Stage 4: Data Extraction

• Objective: Extract the necessary data fields from the collected


datasets for further analysis.

• Activities: Specific data fields like age, gender, comorbidities,


surgery details, and recovery indicators are extracted from the
broader datasets. This ensures that only the most relevant
information (for the use case) is used for building the model.

• Role: Data Engineer

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study

Stage 5: Data Validation and Cleansing

• Objective: Validate and clean the data to ensure its accuracy and
reliability.

• Activities: The data undergoes a thorough cleansing process, where


missing values are imputed, outliers are identified and treated, and
data types are standardized. For example, numerical data like age
and surgery duration may be normalized, while categorical data like
surgery type is encoded.

• Role: Data Analyst

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study

Stage 6: Data Aggregation & Representation

• Objective: Aggregate and represent the data in a way that is suitable


for analysis.

• Activities: The data from multiple sources (e.g., pre-operative, intra-


operative, and post-operative data) is aggregated to create a
comprehensive dataset for each patient. Features are engineered,
such as creating risk scores based on multiple health indicators,
which can be used as inputs for the classification models.

• Role: Data Architect, Data Scientist

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study

Stage 7: Data Analysis


• Objective: Perform analysis to build predictive models that classify
patient survival.
• Activities:
• Perform Exploratory Data Analysis (EDA), which involves univariate,
bivariate and multivariate analysis
• Build ML models using classification algorithms like SVM, Random
Forest, ANN etc.
• Evaluate the performance of the models, using metrics like Accuracy,
Precision, Recall etc.
• Role: Data Scientist

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study

Stage 8: Data Visualization

• Objective: Visualize the results of the data analysis to gain insights


and communicate findings.

• Activities: Visualization using charts, graphs, dashboards. These


visualizations help stakeholders understand the model’s performance
and the factors most strongly associated with survival. [Ex: Python,
Tableau, Power BI etc.]

• Role: Data Scientist, Data Visualization Engineer

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Case Study

Stage 9: Utilization of Analysis Results

• Objective: Apply the results of the analysis in a practical setting to


improve decision-making.
• Activities: The predictive model is deployed within the hospital’s
clinical decision support system. Real-time predictions are provided
for patients scheduled for cardiac surgery, allowing healthcare
providers to identify high-risk individuals and take preventive
measures, such as closer monitoring or additional interventions post-
surgery.
• Role: Machine Learning Engineer, Business Team, Intervention
Team / Program Director, Clinical Staff, IT Team

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
API-driven Cloud Native
Solutions
BITS Pilani Dr. Shreyas Rao
Associate Prof, Dept. of CSIS, BITS-Pilani
BITS Pilani

CC ZG506 / SE ZG506
Lectures No. 5 and 6
Agenda

 Data Science Project with Demo


 DataOps
 Building a Cloud-native Data Pipeline and accessing the
application using APIs
 Tools: Prefect, Prefect Cloud

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani

Data Science Project with Demo


Types of Data

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Types of Data

Nominal: Distinctiveness

Ordinal: Order, the data


can be categorized and
ranked.

Interval: the data can be


categorized and ranked,
and evenly spaced.

Ratio: the data can be


categorized, ranked,
evenly spaced and has a
natural zero.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Types of Data - Example

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Data Science Project

Minimal Example
Steps:
1. Data Ingestion [get data from data source]
2. Data Pre-processing or Cleaning
3. Data Exploration – EDA (Exploratory Data Analysis]
4. Data Analysis [ML code]
5. Data Visualization [Python – Matplotlib, Seaborn]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Covid Dataset Overview
• Dataset collected during Covid 2nd Wave April-2021 to June 2021
• Type of Project: Data Science and Machine Learning
Data
• Gender: Categorical (M/F)
• Age: Numeric
• Co_Morbid: Binary (1 = Yes, 0 = No)
• Admit_date & Discharge_date: Dates
• Remdesivir_Given: Binary (1 = Given, 0 = Not Given)
• DaysOfStay: Numeric
• DischargeType: Numeric (1-Recovered; 2-Expired)
• Covid_Severity: Numeric (1 = Mild, 2 = Moderate, 3 = Severe)
• Covid_SeverityDescription: Categorical (Mild, Moderate, Severe)
• DischargeTypeCategorical: Categorical (Recovered, Expired)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Covid Patient Discharge Prediction

• Dataset size: 1233 patients suffering from Covid

• Variables:

• X: Age, Gender, Co_morbid, Admit Date, Discharge date, days of


stay, covid_severity

• Y: Discharge Type (Recovered, Expired)

• Exploratory Data Analysis: Univariate, Bivariate, Multivariate

• Models applied: Support Vector Machine, Naïve Bayes, Logistic


Regression, Decision Trees, KNN, ANN, Random Forest

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Demo

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Supporting Material

Min-Max Scaling
Min-max scaling squeezes (or stretches) all feature values
to be within the range of [0, 1].
Min-Max normalization preserves the relationships among
the original data values.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Supporting Material
Pearson Correlation Statistic
Used to measure the strength of association between two continuous
features.
• The sign of the Pearson correlation gives the direction of the relationship:
• If r is positive, it means that as one variable increases, the other tends
to increase as well
• [0 - 0.5 -> Moderate positive correlation; 0.5 tending towards 1 -> high
correlation]
• If r is negative, then one variable tends to decrease as the other
increases.
• The absolute value gives the strength of the relationship:
• Pearson's r ranges from -1 to +1;
• The closer it is to ±1, the stronger the relationship between the variables;
• If r equals -1 or +1, then the linear fit is perfect: all data points lie on one line;
and
• If r equal 0, it means that no linear relationship is present in the data.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Supporting Material

Chi-Square Statistic
Determines whether or not two categorical variables are
related or not.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani

DataOps
Need for DataOps

• Can DevOps principles directly be applied to Data


Science processes?
• What are the hindrances?
• Can data and code be treated the same way? For
example, in DevOps, a working code is delivered to end-
users at the end of CI/CD. Will a refined, pre-processed
data be available for analysis to the Data Analysts or
Data Scientists in the same agile way?

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Data Challenges

• Adoption of DevOps to Data Science discipline is slow and


gradual
• Data Science, and Data Exploration in particular are more
exploratory process, compared to software development.

Bottlenecks
• Data Collection (more sources added or removed constantly)
• Data Cleansing
• Data Exploration (Univariate, Bivariate and Multivariate analysis)
• Data Pipeline environments more difficult to reproduce compared to
software application environments

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


DataOps

• It is a way to streamline, manage, and automate data


flow within an Organization.
• Implementing DevOps strategies
• Includes Data Ingestion, transformation, processing,
analysis
• Reduces time and resources required to manage the
infrastructure

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


DataOps definition

• Gartner

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


DataOps definition
• DataKitchen

DataOps = Agile Practices + Lean Thinking + Data Analytics + DevOps

• Agile Practices ensure that we work on the “right things” that add value for the
“right people”

• Lean Thinking focuses on eliminating waste and bottlenecks, improving quality,


monitoring data flows, and making data cheaper for consumers

• DevOps practices build a culture of collaboration between historically siloed


teams.

• Data Analytics - Descriptive, Diagnostic, Predictive and Prescriptive.

• Brings together self-contained teams having Data Analysts, Data Scientists, Data
Engineers, Machine Learning Engineers and DevOps Engineers.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


DataOps

DevOps concepts used in DataOps


• Source Code Management (Git)
• Continuous Integration (CI)
• Continuous Delivery / Deployment (CD)
• Operations : Monitoring and Logging [Observability]
• Culture: Collaboration and Communication

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Canonical Data Architecture

[Link]
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
DataOps Functional Architecture

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


DataOps Automation

1. Orchestrates, tests, and monitors the data pipeline.


2. Automate the process
• Data flows in from tens, hundreds or thousands of
sources and is integrated, cleaned, processed, and
published for analytics.
• Check data for anomalies
• For data errors, notify test results
• Dashboard – View metrics based on monitoring

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


DataOps Tools

Open Source options


• Apache AirFlow [Workflow automation tool]
• Prefect [Workflow automation tool] and Prefect Cloud
• DagSter [ETL pipelines and ML pipelines]
• Curated list of DataOps tools -
[Link]

Commercial options
• DataKitchen [DataOps tool]
• Unravel [Data Observability tool]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani

Building a Cloud-native
Data Pipeline and Accessing using APIs
Prefect - Data Orchestration Tool

• Workflow orchestration tool for data scientists and ML


engineers
• Only knowledge of Python is required, easy to learn [Pythonic]
• Open source [Hobby edition]
• Prefect Cloud is a cloud-native workflow engine
• REST API access for data management
• Transforms Python code into production-ready data pipelines
• Tools to build, monitor, and scale critical data workflows

URL - [Link]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Prefect

Pre-requisites
1. pip install -U prefect
2a. Run Prefect on the Cloud
[URL - [Link]
prefect cloud login [Log in with a browser]
OR
2b. Run prefect locally -> prefect server start

URL - [Link]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Prefect Architecture
Account ID PREFECT CLOUD
Workspace ID
Prefect API Key Workspace

Schedule or
Deployment
trigger

Flow Run(s)
Python
Functions with
annotators
@flow or @task
Task(s)

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Data Science Project

Steps: One Deployment


1. Data Ingestion [get data from data source]
2. Data Pre-processing or Cleaning One Main Flow
3. Data Exploration – EDA (Exploratory Data Analysis] Tasks for each
4. Data Analysis [ML code] activity
5. Data Visualization
Scheduled runs

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Prefect Demo - I

Minimal Example
Steps
1. Import required library -> "Pima-Indian Diabetes dataset"
[Classification]
2. Data Pre-processing
3. Model Training using Logistic Regression Model
4. Define the Prefect Flow and all the related tasks
5. Calculate the Accuracy and display in the "Prefect Cloud
– Dashboard"

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Prefect Demo - II

• Full Workflow demonstration for a Data Science Project

• Executing the Project from VS Code terminal and running


on Prefect Cloud.

• Objectives: Observe the deployment, runs, flows and


tasks in the Prefect Cloud Dashboard

[Link]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Folder Structure

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Prefect APIs

• Prefect Cloud provides a REST API that allows you to interact


with various entities, such as deployments, flow runs, task
runs, etc.
• You can use this API to programmatically access data about
your deployments and their runs.

Step 1: Get Prefect Cloud API Key

Step 2: Prefect Cloud REST API Access


• [Link]
4511-869f-eeec8ad55a87

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Prefect APIs

• Use the Prefect REST APIs, to get the following


information:

• Deployment details

• Flow details

[Link]

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Adding CI using GitHub Actions
- [Link] file

name: Prefect CI/CD Pipeline with Prefect Cloud - name: Install dependencies
run: |
on: python -m pip install --upgrade pip
push: pip install -r [Link]
branches: [main]
pull_request: - name: Authenticate with Prefect Cloud
branches: [main] env:
PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }}
jobs: WORKSPACE_KEY: ${{ secrets.WORKSPACE_KEY }}
run-prefect-workflows: run: |
runs-on: ubuntu-latest prefect cloud login --key $PREFECT_API_KEY --workspace
'shreyas-rao/default'
steps:
- name: Check out repository - name: Run Prefect deployment on Prefect Cloud
uses: actions/checkout@v2 env:
WORKSPACE_KEY: ${{ secrets.WORKSPACE_KEY }}
- name: Set up Python 3.10 run: |
uses: actions/setup-python@v2 prefect deployment run 'main-flow/covid-ds-workflow' --
with: workspace-key $WORKSPACE_KEY
python-version: '3.10'

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


GitHub Actions

• GitHub’s native CI/CD and automation system


• GitHub Actions was introduced by GitHub in 2018.
• It is integrated right into GitHub and enabled by default in
every GitHub repository.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


Typical GitHub Actions – Workflow structure

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


GitHub Actions

A workflow is triggered by one


or more events. Event can be
internal (push or PR) or
external (webhook call)

A job contains a set of


commands that will be run
when the workflow is triggered

A runner is a virtual machine


hosted by GitHub with an
operating system. Each job
runs inside a container
A step is either a shell
command or an action

An action is a reusable unit of


code which can be included
as a step of a job. Actions can
have inputs and outputs.

BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956


BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
API-driven Cloud Native
Solutions
BITS Pilani Dr. Shreyas Rao
Associate Prof, Dept. of CSIS, BITS-Pilani
BITS Pilani

CC ZG506 / SE ZG506
Lectures No. 7
Agenda

• Machine Learning
• Generations
• Machine Learning Pipeline
• MLOps
• Tools: MLFlow and AWS SageMaker
• API-driven ML pipelines
– Model Development and Training
– Model Deployment
Work Integrated Learning
– Monitoring Programmes
– Scalability

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Machine Learning
Machine Learning

Machine learning (ML) is a branch of artificial intelligence (AI) and computer science
that focuses on using data and algorithms to enable AI to imitate the way that
humans learn, gradually improving its accuracy.

BITS Pilani, Pilani Campus


Machine Learning Complexity

Number of changing variables - 3 (Data, Model and Code), whereas in


pure software development, only changing variable is Code

[Link]

BITS Pilani, Pilani Campus


Model in ML

A model in Machine Learning is the trained algorithm used to make predictions or


decisions, and it forms the core of a machine learning system that is developed,
deployed, monitored, and maintained as part of an operational pipeline.

BITS Pilani, Pilani Campus


Model Workflow

1. Model Development: Building and training the model using training data. This involves
selecting an algorithm, tuning hyper parameters, and evaluating performance.
2. Model Versioning: Keeping track of different versions of a model, which may be developed
over time to improve accuracy or adapt to new data.
3. Model Deployment: Taking the trained model and deploying it into a production
environment where it can make predictions on live data.
4. Model Monitoring: Continuously monitoring the model's performance in production to
ensure that it is accurate and effective. This may involve detecting data drift, model
degradation, or biases.
5. Model Retraining: Updating or retraining the model periodically with new data to maintain its
performance over time.

BITS Pilani, Pilani Campus


High Bias in Dataset

Bias is the error that calculates the difference between the


average prediction of our model and the actual value that we
are trying to predict.
A model suffering from high bias is a simple model which
pays very little attention to the training data.
This type of model always leads to a high error on
both training and test data.
Let’s take an example.
Ex: In Covid dataset, if the model is
Suppose we want our model to predict the animal by showing
trained mainly on “Recovered”
photos of animals. class, it will fail to predict outcomes
We trained the model on only one attribute pointing-ears. for “Expired” class well.
Then we showed the image of a cat to the model.
[Too much data belonging to a
single ‘Y’ type]
So the model predicted it as a fox also has pointed ears.

BITS Pilani, Pilani Campus


High Variance in Dataset

Variance is the opposite of Bias. In a Classification problem, too


many ‘Y’ outcomes
Variance can be defined as the model’s [Multiple classes]
sensitivity to fluctuations in the data, if the
model is allowed to view the data too many
times, it will learn very well for only that data. Ex: In Covid dataset, if there were 5
outcomes, and each outcome had
It will capture most patterns in the data, but it only 10 rows of data, it may be
will also learn from the unnecessary data overfitted.
Any test value will likely be
present, or from the noise. overfitted.

We need to ensure “low variance and low bias” in the training dataset

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Machine Learning Generations


Three Generations of ML

Gen 1: Basic Machine Learning

Gen 2: Deep Learning [based on Artificial Neural Networks]

Gen 3: Transfer Learning / Transformers

BITS Pilani, Pilani Campus


Gen 1. Basic Machine Learning

This generation includes traditional machine learning algorithms that rely on


manually engineered features and mathematical models to find patterns in data.
These algorithms typically perform well on structured data and smaller datasets.

Algorithms for solving Classification problems:


• Naïve Bayes
• Decision Tree
• Random Forest
• Support Vector Machine (SVM)
• K-Nearest Neighbors (KNN)
• Logistic Regression

BITS Pilani, Pilani Campus


Gen 2. Deep Learning

Deep Learning models are based on artificial neural networks with many layers
(hence "deep") that automatically learn features from the data. They perform well on
large datasets and can handle unstructured data such as images, text, and audio.

• Convolutional Neural Networks (CNNs) - for Image Processing & Video Analysis
• Recurrent Neural Networks (RNNs) - NLP, speech recognition, and time series
analysis
• Long Short-Term Memory Networks (LSTMs) - NLP

BITS Pilani, Pilani Campus


Gen 3. Transfer Learning / Transformers

This generation leverages pre-trained models on large datasets and fine-tunes them
on specific tasks. Transfer learning and transformers allow models to learn more
effectively with less data and training time.

Ex: ChatGPT 4.0 or 01 models for NLP tasks like sentiment analysis, language
translation, text summarization etc.

BITS Pilani, Pilani Campus


Transfer Learning

Transfer learning is a deep-learning technique where a model


is first pre-trained on a data-rich task before being fine-tuned
on a downstream task, has emerged as a powerful technique
in natural language processing (NLP).

The effectiveness of transfer learning has given rise to a


diversity of approaches, methodology, and practice.

BITS Pilani, Pilani Campus


Transfer Learning

Model developed for task 1 is reused for other tasks

BITS Pilani, Pilani Campus


Transformer Architectural Models

Transformer Model Company / Organization & Info


Google / Microsoft Bidirectional language understanding Used
BERT Family (Encoder-based Models) • BERT Base & Large •
for Search Ranking, NLP pipelines, Semantic Retrieval,
DeBERTa (Decoding-enhanced BERT) • ModernBERT (efficient
Enterprise AI Tasks: Classification, NER, QA, Information
long-context variant)
Retrieval
OpenAI Large-scale autoregressive foundation models Tasks:
GPT Family (Decoder-based Models) • GPT-3 → GPT-4 → GPT-
Text generation, Coding, Reasoning, Agents, Summarization,
4o / GPT-4.1 / GPT-5 class models • Multimodal Transformers
Conversational AI Backbone of modern AI assistants & Agentic
(Text + Image + Audio + Video)
AI systems
Google Research Unified Text-to-Text framework Instruction-
T5 / FLAN-T5 (Text-to-Text Transformers) tuned models (FLAN) improved reasoning ability Tasks:
Translation, QA, Summarization, Instruction Following
Meta (Facebook AI) Open-weight large language models
LLaMA Family (Open Foundation Models) • LLaMA-2 •
Widely used for enterprise private AI and on-prem deployment
LLaMA-3 / 3.1 / 3.2 / 3.3 / 3.4 / 3.5
Supports fine-tuning & RAG applications
Google DeepMind Native multimodal transformer architecture
Gemini Models (Formerly PaLM) Advanced reasoning + long-context understanding Used in
Search, Workspace AI, Agents
Mistral AI Sparse MoE architecture for high efficiency Strong
Mistral & Mixtral (Mixture-of-Experts Transformers) performance with lower compute cost Popular in open
enterprise deployments
Anthropic Safety-aligned large transformers Long-context
Claude Models (Constitutional AI Transformers)
reasoning (100K+ tokens) Enterprise knowledge assistants

BITS Pilani, Pilani Campus


Machine Learning Types

Search for Datasets and Models - [Link]

BITS Pilani, Pilani Campus


Machine Learning Life Cycle

BITS Pilani, Pilani Campus


Model Evaluation Metrics

Evaluation Metrics vary based on type of models:

Regression Models
• Mean Absolute Error (MAE)
• Root mean squared error (RMSE)
• R Squared or Adjusted R Square

Classification Models
• Confusion Matrix
• Accuracy (%)
• Precision
• Recall
• F1-score

Refer PPT – “Classification - Confusion Matrix and Metric calculations"


BITS Pilani, Pilani Campus
BITS Pilani
Pilani Campus

SEMMA Methodology
SEMMA

• SEMMA stands for


Sample, Explore, Modify,
Model, Assess
• SEMMA is focused on
the model development
aspects of data science,
ideal for “Machine
Learning” projects
• Ideal for the Data Analyst
/ Data Scientist roles

BITS Pilani, Pilani Campus


SEMMA

1. Sample
• Sampling the data by extracting a portion of a large data set big enough to
contain the significant information, yet small enough to manipulate quickly.
• Partitioning the data to create training and test samples.
• Identifying dependent and independent variables influencing the process.
2. Explore
• Exploration of the data by searching for unanticipated trends and anomalies
in order to gain understanding and ideas.
• Perform Univariate analysis (single variable) and multivariate analysis
(relationships)
3. Modify
• Modification of the data by creating, selecting, and transforming the
variables to focus the model selection process.

BITS Pilani, Pilani Campus


SEMMA

4. Model
• Apply variety of machine learning techniques to produce a projected model
[Basic Machine Learning, Deep Learning, Transfer Learning]
5. Assess
• Assessing the data by evaluating the usefulness and reliability of the
findings from the ML process and estimate how well it performs. Deploy the
selected best model.

BITS Pilani, Pilani Campus


SEMMA - Case Study

Covid Patient Discharge Prediction (Dataset: 2nd Wave April-2021 to June 2021)

Type of Project: Machine Learning


[Link] : Dataset size: 1233 patients suffering from Covid
[Link]: Univariate (Null values, Mean, basic statistics), Bivariate (correlation –
pearson, chi square)
[Link] : PCA (Principal Component Analysis)
[Link] : Feature Engineering, Subset selection
Final Variables:
X: Age, Gender, Co_morbid, Admit Date, Discharge date, days of stay,
covid_severity
Y: Discharge Type (Recovered, Expired)
Models applied: Support Vector Machine, Naïve Bayes, Logistic Regression,
Decision Trees, KNN, ANN, Random Forest
5. Assess: Best Model with highest Accuracy

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

MLOps
MLOps

• MLOps stands for Machine Learning Operations.


• A set of practices to standardize and streamline the process of developing and
deploying machine learning models.
• It covers the entire machine learning workflow, including data collection,
machine learning model development, training, deployment, and model
management.

[Link]

BITS Pilani, Pilani Campus


MLOps Lifecycle

[Link]

BITS Pilani, Pilani Campus


MLOps Components

[Link]

BITS Pilani, Pilani Campus


MLOps Tools Landscape

BITS Pilani, Pilani Campus


MLFlow

• MLflow is an open-source platform.

• MLflow allows us to log parameters, code versions, metrics, and artifacts for
each run, making it easier to keep track of experiments and results

• Developed by Databricks, MLflow provides a suite of tools to streamline the


process of developing, deploying, and monitoring machine learning models.

• It is particularly useful for organizations and teams working on multiple


machine learning projects that require collaboration, reproducibility, and
scalability.

Ref: [Link]

BITS Pilani, Pilani Campus


MLFlow Components

Ref: [Link]

BITS Pilani, Pilani Campus


Experiment Tracking

• Purpose: Helps track and log the details of machine learning experiments,
such as model parameters, metrics, artifacts, and source code versions.

• Features: Provides a user-friendly interface to view and compare multiple


experiments, making it easier to reproduce results and manage the
progress of different ML models over time.

BITS Pilani, Pilani Campus


Visualization

• Purpose: Offers tools to visualize various metrics and outputs from


experiments, such as accuracy, and performance metrics.

• Features: Allows users to create interactive plots to analyze and compare


results across multiple runs, helping in identifying trends, anomalies, and
the best-performing models.

BITS Pilani, Pilani Campus


Generative AI

• Purpose: Focuses on functionalities specific to generative AI models, such


as managing experiments related to text generation, image synthesis, or
other generative tasks.

• Features: Could include features for tracking, evaluating, and optimizing


generative models, though this specific area may depend on the MLflow
version or plugins in use.

BITS Pilani, Pilani Campus


Observability

• Purpose: Provides insights into the operational aspects of ML models, such


as monitoring model performance, drift, and data changes over time.

• Features: Helps track models in production, ensuring they continue to


perform as expected. It might include alerts for model degradation or
unexpected behavior.

BITS Pilani, Pilani Campus


Evaluation

• Purpose: Offers tools to evaluate model performance based on different


metrics.

• Features: Can automate the process of evaluating models against specific


criteria or datasets, providing a consistent method to assess model quality
and suitability for deployment.

BITS Pilani, Pilani Campus


Models

• Purpose: Central place to manage different versions of models.

• Features: Includes a model repository where users can register and store
trained models, manage model versions, and track their deployment status.
It enables collaboration among teams by sharing model artifacts and
versions.

BITS Pilani, Pilani Campus


Model Registry

• Purpose: Provides a collaborative platform to manage the full lifecycle of


machine learning models, from development to deployment.

• Features: Supports model versioning, stage transitions (such as staging to


production), annotations, and approval processes. Ensures a controlled and
organized way to handle model versions and their lifecycle management.

BITS Pilani, Pilani Campus


Serving

• Purpose: Facilitates the deployment of ML models to production


environments.

• Features: Provides tools to deploy models as REST APIs or integrate them


into existing applications or microservices, supporting real-time predictions
and scalability. It helps automate the deployment process and ensures
models are easily accessible for use.

BITS Pilani, Pilani Campus


MLFlow Demo for Covid Dataset

Objective
• To demonstrate a simple MLOps experiment using the
“MLFlow” tool

Main (function)
-> preprocess_data
-> train_model
-> evaluate_model
-> log_to_mlflow

BITS Pilani, Pilani Campus


Metrics Summary

[The parameters may change based on your execution details]

Accuracy (0.785): The model correctly predicted about 78.5% of the instances.

CPU Usage (11.7%): The model used 11.7% of the CPU's processing capacity during
execution.

Memory Usage (87.4%): The model used 87.4% of the system's memory during execution.

Model Training Time (0.08 seconds): The model took about 0.08 seconds to train.

BITS Pilani, Pilani Campus


MLFlow - Artifacts

MLmodel: Defines the model's metadata and structure, specifying the model type,
dependencies, and entry points for loading and running the model.

[Link]: Captures the Conda environment configuration, listing all dependencies and their
versions to recreate the environment for running the model.

[Link]: Stores the serialized (pickled) version of the trained model, allowing it to be loaded
and used for predictions without retraining.

python_env.yaml: Specifies the Python environment, including the Python version and pip
dependencies, ensuring the model runs consistently across different setups.

[Link]: Lists all Python dependencies required to run the model, serving as an
alternative to [Link] for environments that use pip instead of Conda.

*pip is a package manager ONLY for python. Use pip if your project is python-only, and no
dependencies on other languages

*conda is multi-language package manager. Resolves dependencies across languages.

BITS Pilani, Pilani Campus


Types of System Metrics in MLFlow

cpu_utilization_percentage

system_memory_usage_megabytes

system_memory_usage_percentage

gpu_utilization_percentage

gpu_memory_usage_megabytes

gpu_memory_usage_percentage

gpu_power_usage_watts

gpu_power_usage_percentage

network_receive_megabytes

network_transmit_megabytes

disk_usage_megabytes

disk_available_megabytes

Ref - [Link]

BITS Pilani, Pilani Campus


MLOps Demo using SageMaker

• Amazon SageMaker is a MLOps platform


• Build, train, and deploy machine learning (ML) models for any use case with
fully managed infrastructure, tools, and workflows

BITS Pilani, Pilani Campus


SageMaker

[Link]
by=[Link]&[Link]-order=desc

BITS Pilani, Pilani Campus


Sagemaker Canvas vs Studio

1. SageMaker Canvas: Low-code/no-code interface designed to make it easier


for users without extensive machine learning expertise to build, train, and deploy
machine learning models. It offers a visual interface where users can drag and
drop components to define the data flow and model training process.

2. SageMaker Studio: Is an integrated development environment (IDE) for


machine learning. It provides a full-featured environment for data scientists and
machine learning engineers to build, train, tune, deploy, and monitor machine
learning models at scale. SageMaker Studio offers a range of tools and features,
including Jupyter notebooks, experiment management, model debugging, and
automated model tuning.

BITS Pilani, Pilani Campus


Sagemaker

1. Data Wrangler
2. Dataset: “Pima Indian Diabetes” Dataset
3. Model: AutoML model created by SageMaker [Auto ml systems automatically
find, select, and optimize the best machine-learning model for a given dataset
using sophisticated methods and techniques. ]
4. Model Building: Select dataset -> Build -> Analyze -> Predict -> Deploy
[It will deploy to an endpoint, from where predictions can be made]
5. SageMaker Model Registry - SageMaker Model Registry can be used to
catalog and manage different model versions.

BITS Pilani, Pilani Campus


Sagemaker

Demo of “Quick Build AutoML Model” for


Pima Indian Diabetes Dataset

BITS Pilani, Pilani Campus


Thank You!
API-driven Cloud Native
Solutions
BITS Pilani Dr. Shreyas Rao
Associate Prof, Dept. of CSIS, BITS-Pilani
BITS Pilani

CC ZG506 / SE ZG506
Lectures No. 8
Contact Session wise Coverage

Sessio Coverage
n
CS01 API Basics (OpenAPI, REST, gRPC, GraphQL)
CS02 API Basics + Cloud Native Application Basics
CS03 Cloud Native Application
CS04 Introduction to Data Science & Machine Learning, DataOps & MLOps Data
CS05 API driven Cloud-native Data Pipeline
Science
CS06 API-driven ML pipelines
& ML
CS07 Tools review; Case Study
CS08 Basic APIs for AI Applications – NLP, CV, Speech recognition
CS09 Language Models (LLMs) Cognitive
CS10 RAG Models AI
CS11 Work Integrated Learning Programmes
RAG Models
CS12 Cloud Native Application Deployment
CS13 IoT and Data Analytics
CS14 APIs for IoT and Data Analytics IoT
CS15 Serverless Functions; Case study
CS16 Course review and discussion

BITS Pilani, Pilani Campus


Agenda

AI and Cognitive Services


Part-A: Basic APIs for AI applications
• Hugging Face APIs
• Natural Language Processing APIs
• Computer Vision APIs
• Speech Recognition APIs

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

AI and Cognitive Services


AI, ML and Generative AI

Ref: Adapted from 'AWS Innovate Conference, 2024', Presentation by Melwin Pais, Senior Solution
Architect, AWS

BITS Pilani, Pilani Campus


AI Use Cases

Ref: Adapted from 'AWS Innovate Conference, 2024', Presentation by Melwin Pais, Senior Solution
Architect, AWS

BITS Pilani, Pilani Campus


Three Generations of Machine Learning

Gen 1: Basic Machine Learning


Effort: Create Labeled datasets, Train Models using basic ML algorithms, Measure
Performance

Gen 2: Deep Learning [based on Artificial Neural Networks]


[Emergence of Big Data]
Effort: Re-Train Models using DL algorithms and measure performance

Gen 3: Transfer Learning / Transformers


[Pre-trained models / Fine-tuned models available]
Effort: Use APIs in various applications on a pay-per-use basis. No model training
required
BITS Pilani, Pilani Campus
Pre-Trained Model

• Pre-trained models are machine learning models that have


already been trained on large amounts of data before being
used for a specific task.
• Pre-trained models are general-purpose base models
• Pre-training is computationally intensive.

BITS Pilani, Pilani Campus


Fine-Tuned Models

Fine-tuning means continuing the training of an existing model on new, task-


specific data. Ex: Take a General LLM and train on Medical Q&A data.
Performance
Fine-tuning can improve a model's performance on specific tasks, and can
often outperform models trained from scratch.
Transfer learning
Fine-tuning allows models to apply knowledge gained from one task to
another, potentially unrelated task.
Interpretability
Fine-tuning can make models more interpretable, which can help with
debugging and understanding the model's behavior.

BITS Pilani, Pilani Campus


Pre-Trained vs Fine-Tuned Models

BITS Pilani, Pilani Campus


AI-based Cognitive Services

Cognition – “Mental action or process of acquiring knowledge and understanding


through thought, experience, and the senses”

• Cloud-based cognitive services are a set of AI-powered APIs and tools provided
by cloud platforms (such as Microsoft Azure, AWS, or Google Cloud) that enable
developers to easily integrate AI functionalities into their applications without
needing in-depth knowledge of AI or machine learning.
• These services use cloud infrastructure to offer scalable, ready-to-use models and
algorithms for tasks involving human-like cognitive abilities.

BITS Pilani, Pilani Campus


Cognitive Services

Ex: Azure AI Services

• Set of cloud-based APIs that you can use in AI applications and data flows.
• It provides pretrained models that are ready to use in your applications, requiring
no data and no model training on your part.
• The services are developed by the Microsoft AI and Research team and expose
the latest deep learning algorithms.
• They're consumed over HTTP REST interfaces.
• In addition, SDKs are available for many common application development
frameworks.

[Link]

BITS Pilani, Pilani Campus


Benefits

• Minimal development effort for state-of-the-art AI services.


• Use predefined algorithms or create custom algorithms on top of pre-built
libraries.
• Easy integration into apps via HTTP REST interfaces.
• Developers and data scientists of all skill levels can easily add AI capabilities to
apps.

[Link]

BITS Pilani, Pilani Campus


Types of Services

Service Description
Language Services that provide Natural Language Processing (NLP)
features for understanding and analyzing text.
Speech Services that provide speech capabilities like speech-to-text,
text-to-speech, speech translation, and speaker recognition
Computer Vision Services that provide image and video recognition
capabilities
Decision Services Services that provide NLP features to produce
recommendations for informed and efficient decision-
making
Azure OpenAI Service Service provides REST API access to powerful OpenAI
language models.

[Link]

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

HuggingFace
Kaggle vs HuggingFace

• Kaggle is a popular dataset store for Generation 1 ML and Generation 2 DL


• URL - [Link]

• HuggingFace is a popular dataset and model store for Generation 3 Transformers


• URL - [Link]

BITS Pilani, Pilani Campus


HuggingFace

• HuggingFace Hub is a open source platform for hosting:


– Git-based code repositories, including discussions and pull requests for
projects.
– Models, also with Git-based version control
– Datasets, mainly in text, images, and audio

BITS Pilani, Pilani Campus


HuggingFace APIs

• Hugging Face APIs are cloud-based cognitive services, particularly in the areas of
NLP, CV and Speech recognition.
• Hugging Face provides a variety of pre-trained models and APIs that developers
can use to build intelligent applications without needing to train models from
scratch [For Inferencing purposes]

• Website - [Link]

BITS Pilani, Pilani Campus


HuggingFace Key Terminologies

Task
• Tasks refer to the specific machine learning or AI problems that you want to solve
using Hugging Face models.
• Each task represents a different type of problem, often tied to a particular
application of machine learning or NLP.

Common tasks in Hugging Face:


• Text Classification: Categorizing text into predefined categories (e.g., sentiment
analysis, spam detection).
• Named Entity Recognition (NER): Identifying and classifying entities (such as
people, locations, organizations) in text.

BITS Pilani, Pilani Campus


Task

Common Tasks
• Text Generation: Generating text, such as autocompleting or generating a paragraph from a
prompt (e.g., using GPT models).
• Machine Translation: Translating text from one language to another.
• Question Answering: Answering a question based on a given passage or context (e.g.,
SQuAD-style tasks).
• Summarization: Creating a shorter version of a longer text while preserving the core
meaning.
• Image Classification: Classifying images into predefined categories (using models trained
on images).
• Speech Recognition: Converting spoken language into written text.
• Object Detection: Identifying objects within an image.
Hugging Face provides an extensive list of pre-built models tailored to each of these tasks.

BITS Pilani, Pilani Campus


Models

• Models in Hugging Face refer to the machine learning models that are pre-trained
to solve specific tasks.

These models can be either:


1. Pre-trained: Already trained on large datasets for common tasks (e.g., language
modeling, text classification, translation).
2. Fine-tuned: Adapted from a pre-trained model to a more specific task using a
smaller, domain-specific dataset.

BITS Pilani, Pilani Campus


Models

Common Model Types


• Transformer-based Models: Hugging Face is known for its support of transformer
architectures, which excel in NLP tasks.

Popular transformer models include:


• BERT (Bidirectional Encoder Representations from Transformers): Used for tasks like text
classification, NER, and question answering.
• GPT (Generative Pre-trained Transformer): Used for text generation and completion.
• T5 (Text-To-Text Transfer Transformer): A versatile model for a variety of text tasks by
framing them as a text-to-text problem (e.g., translation, summarization).
• DistilBERT: A smaller, faster version of BERT with reduced computational requirements.
• RoBERTa, XLNet, ALBERT: Variants of BERT optimized for different tasks or efficiencies.

BITS Pilani, Pilani Campus


Dataset

• Datasets in Hugging Face are collections of data used to train, fine-tune, or


evaluate models.
• Hugging Face provides an extensive hub of datasets that cover a variety of tasks
across different domains.
• These datasets can be accessed through the Hugging Face Datasets library.

BITS Pilani, Pilani Campus


Features of Dataset

Pre-defined datasets
• SQuAD (Stanford Question Answering Dataset): A dataset for question-answering
tasks.
• GLUE (General Language Understanding Evaluation): A collection of datasets for
evaluating NLP models on a wide range of tasks like text classification, sentence
similarity, etc.
• IMDB: A dataset used for sentiment analysis of movie reviews.
• COCO (Common Objects in Context): An image dataset used for image classification
and object detection tasks.
• LibriSpeech: A dataset for speech recognition tasks.
Custom datasets
• You can upload and share your own datasets for use in fine-tuning models

BITS Pilani, Pilani Campus


How Tasks, Models, and Datasets interact

• Tasks define what you want to achieve, such as text classification or translation.
• Models are the pre-trained or fine-tuned algorithms that perform these tasks.
• Datasets provide the necessary training or evaluation data for the models to learn
from or be tested against.

BITS Pilani, Pilani Campus


Example Workflow

1. Task Selection: Choose a task, e.g., sentiment analysis.


2. Model Selection: Pick a pre-trained model like BERT fine-tuned for sentiment
analysis from the Hugging Face Hub.
3. Dataset Selection: Use a dataset like the IMDB movie reviews dataset to fine-
tune or test your model. [Optional]
4. Training or Inference: Train the model on the selected dataset [Fine-Tune] or use
it to make predictions on new data [Inference].

BITS Pilani, Pilani Campus


HuggingFace Model Card

• A model card in Hugging Face is a documentation tool that provides important


information about a specific machine learning model hosted on the Hugging Face
Hub.
• Model cards are designed to offer transparency about a model's performance,
intended use cases, limitations, and the data it was trained on, helping
developers, researchers, and users understand how to effectively and responsibly
use the model.

BITS Pilani, Pilani Campus


Sample HuggingFace Model Card

Model Name: “deepseek-ai/DeepSeek-R1”


Description: DeepSeek-R1 is an open-source, high-performance artificial intelligence
reasoning model developed by Chinese startup DeepSeek. It uses reinforcement
learning to generate detailed "chain of thought" reasoning, allowing it to solve
complex problems, self-correct, and reduce hallucinations
Model Card URL: [Link]

Try “nlptown/bert-base-multilingual-uncased-sentiment” for Sentiment Analysis

Try it out in the Inference Provider!

BITS Pilani, Pilani Campus


Question!

How do you select the appropriate Model


from HuggingFace? Since so many tasks,
models, and datasets are present?

BITS Pilani, Pilani Campus


Answer

There is NO SINGLE solution here


1. Select the kind of problem : General purpose or specific
2. Select the task: NLP, Computer Vision or Speech Recognition etc.
3. Select the sub-task: Text generation or object identification or question
answering or language translation etc.
4. Consider type of Language Model required: Large, Small etc.
5. Consider Performance metrics (Accuracy, F1) of the model if available,
based on the sub-task
6. Test the dataset on various models before final selection. Use “Inference
Providers for quick assessment!”

BITS Pilani, Pilani Campus


Some Models and Tasks - AWS

Ref: Adapted from 'AWS Innovate Conference, 2024', Presentation by Melwin Pais, Senior Solution
Architect, AWS

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Basics of Natural Language


Processing
NLP

 NLP stands for Natural Language


Processing
 Subfield of Computer Science, Human
language (Linguistics), and Artificial
Intelligence
 It is the technology that is used by
machines to understand, analyze,
manipulate, and interpret human's
languages.
BITS Pilani, Pilani Campus
Basics of NLP

 Users can provide two kinds of input to Machine –> Text or Speech
 Machine has to first understand the human speech in order to act on it

Examples:
 User types a message “BITS Pilani” in Google Search
 User tells Alexa “Play me Kishore Kumar Songs”

In both the examples, Machine should understand the Syntax, Semantics,


Context and Intent of the statement, in order to provide a favorable reply.

BITS Pilani, Pilani Campus


Components of NLP

Understands the Process and


Human Speech Action

BITS Pilani, Pilani Campus


Components of NLP

NLU
 Understand the Text
 Understand Syntax, Context, Sentiment, Semantics and Intent from
the text
 Syntactic Analysis
 Lemmatization, Stemming, Word Segmentation, POS tagging etc.
 Semantic Analysis
 Named Entity Recognition (NER), Word Sense Disambiguation
etc.

BITS Pilani, Pilani Campus


Components of NLP

NLG
 Produce meaningful sentences in human-understandable
text
 NLG Models:
 Markov Chain
 Recurrent Neural Network (RNN)
 Long Short-Term Memory (LSTM)
 Transformers

BITS Pilani, Pilani Campus


Sample NLP Pipeline for NLU

BITS Pilani, Pilani Campus


Tools for NLU

 Stanford CoreNLP Parser (Python)


 NLTK – Natural Language Toolkit (Python)
 SpaCy (Python)
 Apache OpenNLP (opensource Java Library)

BITS Pilani, Pilani Campus


Demo

Sample Python Program to demonstrate NLU and NLP Pipeline


using NLTK Library

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Application of Transformers in NLP


Applications of Transformers in NLP

BITS Pilani, Pilani Campus


Applications of Transformers (NLP)

Question – Answering Spam detection


Question Answering focuses on building Is used to detect unwanted e-mails
systems that automatically answer the getting to a user's inbox.
questions asked by humans in a natural
language.
Ex: Virtual Assistants Alexa, Google
Mini)
BITS Pilani, Pilani Campus
Sentiment Analysis

Sentiment Analysis
Also called “Opinion Miningˮ
This application is implemented through a
combination of NLP Natural Language
Processing) and statistics by assigning the
values to the text (positive, negative, or
natural), identify the mood or emotion of the
context (happy, sad, angry, etc.)

BITS Pilani, Pilani Campus


Machine Translation

Machine translation
Is used to translate text or speech from one natural
language to another natural language.

BITS Pilani, Pilani Campus


Text Generation

Text Generation
Used to generate text automatically based on user data and context.

Ex: ChatGPT

BITS Pilani, Pilani Campus


Text Summarization / GEC

Text Summarization / Text Paraphrasing / GEC


Text Summarizer tools: Summarize Bot, Resoomer, SMMRY

Text Paraphrasing tools – Quillbot, Spinbot, Grammarly,


GoParaphrase etc.

GEC (Grammatical Error Checker) - Grammarly

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Practical NLP with Transformers


NLP Task 1 -> Sentiment Analysis

[Comes under “Task Classification” category in HuggingFace]


Usage Example
from transformers import pipeline
classifier = pipeline('sentiment-analysis', model='distilbert-base-uncased-finetuned-
sst-2-english')
result = classifier("I love this movie!")
print(result)
Here “Pipeline” is the high level API

Try it out in Google Colab!


Change “Runtime Type” to “T4 GPU” if required
[Link]

BITS Pilani, Pilani Campus


NLP Task 2 -> Language Translation

Reference - [Link]
[Read the Model Card; Go to -> “Use this Model -> Transformers” and view code]

Also try [Link]

Try it out in Google Colab!

[Link]

BITS Pilani, Pilani Campus


NLP Task 3 -> Question Answering

Reference - [Link]

Try it out in Google Colab!

[Link]

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Computer Vision APIs


Computer Vision

Computer vision is a field that uses algorithms to process images and videos to
perform tasks such as

Object detection
Locating and identifying objects in an image or video. This is
used in many applications, including surveillance, robotics,
image and video analysis.

Face recognition
A widely used application of computer vision, face recognition
is used to unlock devices and identify security threats.

BITS Pilani, Pilani Campus


Computer Vision

Computer vision is a field that uses algorithms to process images and videos to
perform tasks such as

Feature extraction
An essential part of applications that require computer
vision to recognize objects in an image.

Image classification
A fundamental task in computer vision, image
classification identifies the class an input image falls
under.

BITS Pilani, Pilani Campus


Computer Vision

Computer vision is a field that uses algorithms to process images and videos to
perform tasks such as

Image restoration
An important task in computer vision, image
restoration can include image in paintings, image
deblurring, pixel interpolation, and image
denoising

Object Tracking is a continuous CV task that aims to track a specific object or


multiple objects over a sequence of frames

Scene reconstruction is the process of reconstructing a 3D digital version of a


real-world object from pictures or scans of the object
Ex: Generating a 3D model of a historical building using old photos
Colorization is adding realistic colours to black and white pictures.
BITS Pilani, Pilani Campus
CV Task -> Image Classification

Model – “facebook/deit-base-distilled-patch16-224”

Code
from transformers import pipeline
# Load the image classification pipeline
image_classifier = pipeline("image-classification", model="facebook/deit-base-distilled-patch16-224")
# Use a new image URL (make sure it's a valid and accessible image URL)
url = "[Link]
# Perform image classification using the URL directly
result = image_classifier(url)
# Print the result
print(result)

[Link]

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Speech Recognition APIs


Automatic Speech Recognition (ASR)

• Is a technology that converts spoken language into text.

• It's the foundational component in speech recognition systems, enabling


computers and devices to "understand" and process human speech in real-
time or through recorded audio.

• ASR is widely used in applications like virtual assistants (e.g., Siri, Google
Assistant, Alexa), transcription services, call centers, and more.

BITS Pilani, Pilani Campus


Key Features of ASR

• Feature Extraction: The system captures audio features, such as phonemes


(small sound units), tone, pitch, and frequency.

• Acoustic Modeling: This step helps the system recognize various sound
patterns and phonetic elements in speech.

• Language Modeling: The ASR system applies linguistic rules,


understanding grammar, context, and vocabulary, to improve accuracy.

• Decoding: The system processes the audio input to generate the most likely
text output based on the sounds and language patterns.

Modern ASR systems use AI models, especially deep learning, to improve


recognition accuracy and handle nuances like accents, background noise, and
varying speech speeds.

BITS Pilani, Pilani Campus


Case Study:
Sophia Robot by Hanson Robotics

BITS Pilani, Pilani Campus


Sophia Robot by Hanson Robotics

[Link]

Watch from 4.30 minutes till the end of the video

BITS Pilani, Pilani Campus


Thank You!
API-driven Cloud
Native Solutions
BITS Pilani Dr. Shreyas Rao
Pilani Campus Associate Prof. (Off Campus), CSIS, BITS-Pilani
BITS Pilani
Pilani Campus

CC ZG506 / SE ZG506
Lecture No. 9
Agenda

AI and Cognitive Services


Part-A: Basic APIs for AI applications
• What are Language Models?
• LM Types
– Large Language Model (LLM)
– Small Language Model (SLM)

Work Integrated Learning Programmes

BITS Pilani, Pilani Campus


Language Models

• Language models are a type of artificial intelligence (AI) model designed to


understand and generate content based on human language.
• Includes NLU and NLG components.
• They are trained on large datasets of text to learn the patterns, syntax,
semantics, and context within language

BITS Pilani, Pilani Campus


Large Language Models (LLM)

• Large language models (LLMs) are deep learning algorithms that can
recognize, extract, summarize, predict, and generate text based on
knowledge gained during training on very large datasets.
• They are trained on large sets of data, comprising of books, articles, and
web pages.
• These models are designed to understand the context and meaning of text
and can generate text that is grammatically correct and semantically
relevant.
• They can be trained on a wide range of tasks, including language
translation, summarization, question answering, and text completion

Ref: “A Beginners Guide to Large Language Models” by NVidia

BITS Pilani, Pilani Campus


LLM Development Timelines

BITS Pilani, Pilani Campus


Large Language Models (LLM)

What is “Large”??

How Large Language Models work?


[Link]

Ref: “A Beginners Guide to Large Language Models” by NVidia

BITS Pilani, Pilani Campus


What are Model Parameters?

• Parameters are the individual variables within a neural network that are
learned from training data.
• In language models, parameters help the model to interpret relationships
between words, phrases, and concepts.
• These parameters are adjusted during training to minimize prediction error,
allowing the model to generate coherent, contextually accurate text.
• With 175 Billion parameters, GPT-3 can understand subtle relationships
within language, allowing it to generate detailed, contextually relevant
responses to a wide range of prompts.

Ref: “A Beginners Guide to Large Language Models” by NVidia

BITS Pilani, Pilani Campus


Dataset of Web Resources used for building LLMs

• Common Crawl
• Over 250 billion pages spanning 17 years.
• Free and open corpus since 2007.
• Cited in over 10,000 research papers.
• 3–5 billion new pages added each month.
• URL - [Link]

BITS Pilani, Pilani Campus


Common Crawl

Ref: [Link]

BITS Pilani, Pilani Campus


Common Crawl

BITS Pilani, Pilani Campus


What are Tokens?

• In LLMs, tokens are the “smallest units” of text that the model processes

• Tokens are the minimal, discrete pieces of input text that the model
processes. For example, in the phrase "I love programming," tokens could
be individual words ("I," "love," "programming") or even parts of words,
depending on how the model splits them.

• Sub-word tokenization: Most modern LLMs, like GPT and BERT, use
subword tokenization method. For instance, “unbelievable” might be
tokenized as ["un", "believ", "able"]

BITS Pilani, Pilani Campus


Token impact on Cost of LLM

• The tokenization strategy affects the length of input the model can process
at once, which also impacts computational cost.

• For instance, if a model can process 4,096 tokens per request, this
includes both input and output tokens in that limit.

• Prompt: “What is the capital of India?”


• Response: Capital of India is New Delhi
• In this example, if we consider one word as one token, then number of
tokens consumed is 12.

BITS Pilani, Pilani Campus


Popular LLMs

• GPT-5.X (OpenAI)
• Codex (Open AI’s code specific variant)
• LLaMA 4 (Meta)
• Claude 4 / 4.5 / 4.6 (Anthropic)
• Mistral 7B / Mistral Large 3
• Gemini 3.X [Google - Multimodal]
• Grok 4.0 (xAI)
• Qwen 3.5 (Alibaba)
• DeepSeek V3 / R1

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Small Language Models (SLM)


Small Language Models (SLMs)

1. LLMs operate on Billions or Trillions of parameters – require huge computational


power.
2. SLMs operate on a more modest scale, typically ranging from thousands to a few
million parameters.
3. This reduced scale brings about lower computational requirements, rendering
smaller language models more accessible and feasible for organizations or
researchers who may lack the resources to manage the substantial computational
load demanded by larger models.
4. SLMs are smaller, efficient, and deployable on limited hardware
5. They are often fine-tuned for specific domains
6. Ideal for edge devices, real-time applications, and cost-sensitive systems

[Link]
Model

BITS Pilani, Pilani Campus


SLM Advantages

1. Ex: “Phi-4-mini-instruct” model is fine tuned for coding related tasks


2. Efficient resource usage – CPU / Hardware constraints

[Link]
BITS Pilani, Pilani Campus
Popular SLM Models

General Purpose Models


• Gemma (Google) → General NLP, chat, instruction-following [2B, 7B]
• Phi-3 / Phi-4 (Microsoft) → Reasoning, coding, education tasks [3.8B] / [14B]
• TinyLLaMA → Chatbots, basic NLP tasks, edge deployment [1.1B]
• Mistral 7B → General-purpose NLP with strong efficiency [7B]

Code-Focused Models
• Code Llama (Meta) → Code generation, debugging [7B, 13B, 34B]
• StarCoder (BigCode) → Programming assistance, multiple languages [15.5B]
• DeepSeek Coder → Advanced coding + reasoning [1.3B, 6.7B, 33B variants]

BITS Pilani, Pilani Campus


Popular SLM Models

Healthcare / Biomedical
• BioGPT (Microsoft) → Biomedical text generation [347M parameters]
• ClinicalBERT → Clinical notes, medical NLP [110M parameters]

Legal
• LegalBERT → Legal document analysis, contract review [110M – 340M]

Finance
• FinBERT → Financial sentiment analysis, market insights [110M
parameters]

BITS Pilani, Pilani Campus


LLM /SLM Hyperparameters

1. stream=True:
Enables streaming mode, meaning the model will send tokens progressively rather than
waiting for the entire output to complete. This is useful for real-time applications where
partial responses are beneficial, like in chat applications.

2. temperature=0.5:
Controls the randomness or creativity of the model’s responses. Values close to 0 make the output
more deterministic, focusing on likely words, while higher values increase diversity. A setting of 0.5
provides a balance between creativity and predictability, making responses both coherent and
somewhat varied.
Ex 1: For Question Answering, we may want to keep at 0.2-0.3, since we want the answer from the
corpus only. [Factual answer, not imaginative]
Ex 2: For Text generation, like “write a poem”, we may keep temperature = 0.8, to allow creativity
and not restrict to known vocabulary or sentences.

BITS Pilani, Pilani Campus


LLM/SLM Hyperparameters

3. max_tokens=1024:
Sets the maximum number of tokens the model will generate in the output. Tokens
include words, subwords, and punctuation marks, so the output will not exceed this
token limit.

4. top_p=0.7:
Controls nucleus sampling, where the model selects from the smallest group of words
that together have a cumulative probability of 0.7. This constrains the output to likely
options without restricting it too much, promoting coherent but creative responses.
Lower values restrict output to highly likely words, while higher values increase the
diversity of choices.

BITS Pilani, Pilani Campus


LLM/SLM Hyperparameters

Top_p
Sentence – “Once upon a time, there was a dragon who loved to...”

top_p=1.0 (No filtering): The model will have a large pool of tokens to choose from, resulting in
varied responses. It might generate something like:
"...fly over mountains and watch the stars."
"...collect shiny objects and treasure from humans."
"...bake cookies and share them with villagers."

top_p=0.7: With top_p=0.7, the model will only consider tokens that are highly probable, resulting in
responses that are creative but still coherent
"...collect shiny objects."
"...fly over mountains."
"...guard its treasure."

BITS Pilani, Pilani Campus


Thank You!
API-driven Cloud
Native Solutions
BITS Pilani Dr. Shreyas Rao
Pilani Campus Associate Prof. (Off Campus), CSIS, BITS-Pilani
BITS Pilani
Pilani Campus

CC ZG506 / SE ZG506
Lecture No. 10
Agenda
Part-B: Language Models
• Open AI’s API

• Fine Tuning a Model using Open AI’s API

• Differences between “Fine Tuning” and “Context based Approach” for


document Q&A

• AWS BedRock

Work Integrated Learning Programmes

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Open AI API
Open AI API

• OpenAI offers several APIs that allow developers to integrate powerful AI


capabilities into their applications.
• There are Five types of APIs offered by Open AI
1. Chat API / Completion API
2. Embedding API
3. DALL-E API
4. Whisper API
5. Fine-tuning API

[Link]
C?usp=sharing#scrollTo=mM7yW-wkRRry

BITS Pilani, Pilani Campus


Open AI API

Before starting with any of the APIs, first we need to create the “Access
Token”

URL - [Link]

Create Access Token at –> [Link]


Under “Dashboard” -> “API Keys”

Check Usage at -> [Link]


Under “Dashboard” -> “Usage”

BITS Pilani, Pilani Campus


Open AI API

Base Code in “Google Colab” or VS Code

# install openai
pip install openai

# provide the API Key


import openai
openai.api_key = "your_api_key"

BITS Pilani, Pilani Campus


1. Chat API / Completion API

• Used to create conversational AI with natural language understanding and


generation capabilities.
• The API powers chatbot applications, customer service bots, and personal
assistants.
• It supports multi-turn conversations and can remember context within
sessions.
• Popular models include "gpt-3.5-turbo", "gpt-4", "gpt-4o-mini"

BITS Pilani, Pilani Campus


2. Embedding API

• Creates high-dimensional vector representations (embeddings) of text,


which can be used for tasks like similarity matching, classification, and
clustering.
• Used for information retrieval, sentiment analysis, recommendation
engines, and similarity-based search functionalities.

BITS Pilani, Pilani Campus


3. DALL-E API

• Generates images from textual descriptions.


• Used to create images for various applications, including creative content
generation, advertising, and prototyping.

BITS Pilani, Pilani Campus


4. Whisper API

• Transcribes spoken language into text.


• Provides speech-to-text translation with multi-language support and is
highly accurate for clear audio sources.

BITS Pilani, Pilani Campus


DEMO

• Google Colab link ->


• [Link]
LX4u5IC?usp=sharing#scrollTo=mM7yW-wkRRry

BITS Pilani, Pilani Campus


5. Fine-tuning API

• Allows developers to fine-tune models (e.g., GPT-4o-mini) with custom


datasets to perform specialized tasks more effectively.
• Ex: Customer service bots, process documents, tailored educational
models, industry-specific AI applications.

Pre-requisite
• Before Fine-Tuning, we have to prepare our sample dataset in JSONL
format
Ex: {"messages": [{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Is the dissertation project a group project or an
individual project?"}, {"role": "assistant", "content": "It has to be an individual
project. Group projects are not allowed."}]}

BITS Pilani, Pilani Campus


What is Fine-Tuning a LLM

• Fine-tuning LLM involves the additional training of a pre-existing model,


which has previously acquired patterns and features from an extensive
dataset, using a smaller, domain-specific dataset.

Ref: [Link]
fb60abdeba07

BITS Pilani, Pilani Campus


What is Fine-Tuning a LLM

Steps
1. Select a pre-trained LLM model [Ex: “gpt-4o-mini” from Open AI]
2. Gather relevant Dataset [Should be in the “JSONL” format]
3. Pre-process the dataset for any errors or inconsistencies
4. Fine-Tune [Fine tune the pre-trained LLM model for the specific dataset,
and create a “New Model” in the process]
5. Task-specific adaptation [process retains the general language knowledge
gained during pre-training while tailoring the model to the nuances of the
target domain]

Ref: [Link]
fb60abdeba07

BITS Pilani, Pilani Campus


OpenAI’s models for Fine Tuning

• gpt-4o
• gpt-4o-mini
• gpt-4.1
• gpt-4.1-mini
• gpt-4.1-nano
• gpt-5 family -> Fine Tuning not supported

[Link]

BITS Pilani, Pilani Campus


Differences

"Context" based Approach or Prompt


Aspect Fine-Tuned Model
Engineering
Context provided manually for each query
No external context needed; model is pre-
Context Handling [Word or PDF document]
trained
No model re-training
Learns company-specific knowledge from fine-
Knowledge Source Limited to the document uploaded
tuning
Best for focused tasks related to fine-tuned
Scalability Limited to the uploaded document
domain
Uses a pre-trained, general-purpose Tailored to company data through additional
Customization
model training

Domain Specialization General-purpose, non-specialized Highly specialized through fine-tuning

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Demo of Fine Tuning


BITS Pilani
Pilani Campus

AWS Bedrock
AWS BedRock

• Amazon Bedrock is a fully managed AWS service that provides a single


API to access high-performance foundation models (FMs) from AI
companies like Anthropic, Meta, Mistral, Cohere, and Amazon.
• It enables developers to build, customize (via RAG and fine-tuning), and
scale generative AI applications securely without managing infrastructure.

Steps to run Application using AWS BedRock


1. Connect to AWS from API(Console Lab).
2. Default region is "ap-south-1" - Asia-Pacific-Mumbai.
3. In the "Discover" tab, go to "API Keys" and create "Long-term API keys".
4. Write Python code to connect to AWS using the API Key, select any model
from the catalog, and run the application.

BITS Pilani, Pilani Campus


Amazon BedRock

Ref: Adapted from 'AWS Innovate Conference, 2024', Presentation by Melwin Pais, Senior Solution
Architect, AWS

BITS Pilani, Pilani Campus


Amazon BedRock – Choice of Models

Ref: Adapted from 'AWS Innovate Conference, 2024', Presentation by Melwin Pais, Senior Solution
Architect, AWS

BITS Pilani, Pilani Campus


Amazon BedRock – Use Case

Ref: Adapted from 'AWS Innovate Conference, 2024', Presentation by Melwin Pais, Senior Solution
Architect, AWS

BITS Pilani, Pilani Campus


Thank You!
API-driven Cloud
Native Solutions
BITS Pilani Dr. Shreyas Rao
Pilani Campus Associate Prof. (Off Campus), CSIS, BITS-Pilani
BITS Pilani
Pilani Campus

CC ZG506 / SE ZG506
Lecture No. 11
Agenda
Part-B: Language Models

• RAG (Retrieval-Augmented Generation)


– Document Loading
– Document Splitting
– Vectorstores and Embedding
– Retrieval mechanisms
– Question Answering
– ChatbotWork
– design and development
Integrated Learning Programmes

• Visual AI tools
– Rivet
– FlowiseAI

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

RAG
[Retrieval-Augmented Generation]
What is RAG? By Don Woodlock

[Link]

BITS Pilani, Pilani Campus


RAG

• Retrieval-Augmented Generation, or RAG, represents a cutting-edge


approach to Artificial Intelligence (AI) and Natural Language Processing
(NLP).
• At its core, RAG LLM is an innovative framework that combines the
strengths of retrieval-based and generative models, revolutionizing how AI
systems understand and generate human-like text.

[Link]

BITS Pilani, Pilani Campus


Why RAG?

• The development of RAG is a direct response to the limitations of Large


Language Models (LLMs) like GPT.
• While LLMs have shown impressive text generation capabilities, they often
struggle to provide contextually relevant responses, hindering their utility in
practical applications.
• Other approaches such as “Fine-Tuning” and “Context-based (Prompt
engineering using context)” when applied for internal organizational data, have
limitations or restrictions when it comes to volume(s) of data (GBs or TBs) fed
as input to the prompt.
• RAG LLM aims to bridge this gap by offering a solution that excels in
understanding user intent and delivering meaningful and context-aware replies.

[Link]

BITS Pilani, Pilani Campus


Terminologies

• Prompt -> Refers to the user's input or question, which is the initial query that
drives the model's response.
• Context -> The information or data the system refers to when generating a
response. This can include both internal data (pre-loaded knowledge in the
model) and external data (additional documents or information pulled in real-
time).
• LLM -> Refers to Open AIs ChatGpt models (3.5, 4, 4o, 4o-mini, 5.4), Gemini
3.5 or LLama4 etc.

BITS Pilani, Pilani Campus


Terminologies

• Retriever -> is the component that searches a knowledge base (Context) to find
relevant information or documents based on the user's query.

• Embedding: An embedding is a numerical representation of text data, typically


as a vector of numbers, that captures the semantic meaning, enabling the
model to understand similarities between words or phrases.

• Vector Store: A vector store is a specialized database that stores embeddings


(vectors) and allows efficient similarity search, enabling quick retrieval of
relevant information based on proximity in vector space.

BITS Pilani, Pilani Campus


RAG Architecture [Simplistic]

Prompt Generative
part

[Internal Enterprise Data]

BITS Pilani, Pilani Campus


RAG Model [Detailed Architecture]

BITS Pilani, Pilani Campus


Embedding Types

• OpenAI Embeddings: Embeddings generated by OpenAI's models, suitable


for a wide range of NLP tasks.
• BERT Embeddings: Derived from the BERT model, capturing semantic
meaning and context in text.
• Sentence Transformers (e.g., Sentence-BERT): Specially optimized for
sentence and document embeddings, capturing semantic relationships
effectively.
• FAIR’s Dense Passage Retriever (DPR): Optimized for retrieval tasks,
commonly used in open-domain question answering.
• GloVe (Global Vectors for Word Representation): Pre-trained embeddings
that capture semantic relationships between words, though they lack contextual
awareness.

BITS Pilani, Pilani Campus


Vector Stores

• Pinecone: A managed vector database offering scalable and fast similarity search
for high-dimensional embeddings.
• FAISS (Facebook AI Similarity Search): An open-source library by Facebook
optimized for fast, large-scale similarity search.
• Chroma (ChromaDB) is an open-source vector database designed to store,
manage, and retrieve embeddings for AI applications like semantic search and RAG
systems.
• It combines efficient vector indexing with lightweight metadata storage (using
SQLite) for fast, local-first development.
• ElasticSearch with KNN Plugin: A search engine with a plugin for k-nearest
neighbors (KNN) search, enabling vector-based similarity search within text-based
indices.
We will use OpenAI Embeddings and ChromaDB Vector Store for Demo

BITS Pilani, Pilani Campus


ChromaDB

Collection ID: chunk_1


├── IDs Document: "Text from page 1..."
├── Documents (text) Embedding: [0.23, -0.11, ...]
├── Metadata Metadata: {
└── Embeddings (vectors) "source": "[Link]",
↓ "page": 1,
SQLite (storage) "chunk": 1
+ }
HNSW index (fast retrieval)

• ChromaDB stores text in SQLite tables and embeddings as vectors linked to those records.
• Each chunk = one document in ChromaDB
• It uses an HNSW index for fast similarity search over embeddings.
• HNSW (Hierarchical Navigable Small World) index is a data structure used for fast similarity
search

BITS Pilani, Pilani Campus


LangChain

• LangChain is an open-source framework designed to streamline the


development of applications that integrate with language models,
particularly large language models (LLMs) like OpenAI's GPT models.
• It is widely used to build advanced applications such as chatbots, virtual
assistants, document summarizers, and any other software that requires
natural language processing (NLP) capabilities.

BITS Pilani, Pilani Campus


Stages in RAG Model

1. Document Loading
2. Document Splitting
3. Embedding and Vectorstores
4. Retrieval
5. Question Answering
6. Chat

BITS Pilani, Pilani Campus


1. Document Loading

• The document is loaded when the user uploads a PDF through the Google
Colab interface. The code takes the first uploaded file from the dictionary
returned by [Link]() and writes its content to disk.
• The PDF is read using PdfReader, and the text is extracted from each
page. The extracted text is combined into a single string called “raw_text”,
which serves as the full text content for further processing.

BITS Pilani, Pilani Campus


2. Document Splitting

• Since large documents can be difficult to process in one go, the code uses
CharacterTextSplitter to split the raw_text into smaller chunks.
• Each chunk has a maximum size of 1000 characters with a 100-character
overlap, allowing the model to retain context between segments while
staying within token limits.
• Each chunk is then wrapped into a “document” object, which makes it
easier to handle and process in later steps.

BITS Pilani, Pilani Campus


3. Vectorstores and Embedding

• To perform effective retrieval based on the semantic meaning of the text,


each chunk is converted into an "embedding" (a numerical representation
of its content) using OpenAIEmbeddings from the LangChain library.
• These embeddings are then stored in FAISS (Facebook AI Similarity
Search), a vector storage and similarity search tool, allowing the system to
efficiently search through the document chunks to find those most relevant
to any query.
• The FAISS index (stored in “docsearch” variable) is initialized once and
used for all future queries on this document.

BITS Pilani, Pilani Campus


4. Retrieval

• When a query is made, the code retrieves the most relevant chunks of text
based on their similarity to the query.
• The similarity_search function in FAISS finds the top 10 most relevant
document chunks from the vector store, ensuring that only the most
relevant parts are passed to the language model.

BITS Pilani, Pilani Campus


5. Question Answering

• The retrieved chunks are passed to a summarization chain set up using


GPT-4, with the prompt specifying the user’s query.
• This load_summarize_chain function takes the selected documents and
query, instructing the model to provide a summarized response based on
the document contents.
• The result is a concise, relevant answer to the query based on the content
in the uploaded document.

BITS Pilani, Pilani Campus


6. Chatbot

• The code operates as a chatbot, where the user can enter multiple queries
related to the uploaded document. Each query initiates a new retrieval and
summarization process without requiring a new file upload.
• The chatbot continues to accept queries until the user types "exit," at which
point it terminates the session.
• This interactive setup allows users to ask questions about the uploaded
document in a conversational format, with the model providing summaries
in response to each query.

BITS Pilani, Pilani Campus


Key Libraries

• LangChain: Helps with chaining language model tasks.


• FAISS: A library for efficient similarity search.
• PyPDF2: Reads and extracts text from PDF files.
• OpenAI: Provides embeddings and large language models (LLMs).

BITS Pilani, Pilani Campus


Applications of RAG

• Chatbots and AI Assistants [Q&A Scenarios]


• Educational Tools
• Legal Research and Document Review [Summarize statutes,
case law]
• Medical Diagnosis and Healthcare

BITS Pilani, Pilani Campus


Demo of RAG

1. [Link] [Load documents, Split chunks & Build Vector DB]


– Load documents
– Split documents
– Build Vector Store (ChromaDB)

2. [Link] [Streamlit User Interface for the application]


– Call “load vector store” from [Link]
– Call Build Rag Chain” from [Link]
– Call “ask” – Returns answer to the question

3. [Link] [Core RAG functionality]


– Provide the PromptTemplate
– Provides Vector store func, Builds RAG chain & answers QA

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Visual AI Tools
BITS Pilani
Pilani Campus

Rivet
Rivet

• Rivet is an open source visual programming


environment for building AI agents with LLMs.
• Iterate on prompt graphs in Rivet, then run them directly
in your application.
• With Rivet, teams can effectively design, debug, and
collaborate on complex LLM prompt graphs, and deploy
them in their own environment.

BITS Pilani, Pilani Campus


Demo of Rivet Tool

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Flowise AI
Flowise AI

• Flowise is an open-source, low-code platform that lets


you build AI agents and LLM workflows using a visual
drag-and-drop interface instead of writing code.

• It allows you to connect models, data sources, tools,


and APIs as blocks to create applications like chatbots,
RAG systems, and autonomous agents quickly.

BITS Pilani, Pilani Campus


Demo of Flowise AI

BITS Pilani, Pilani Campus


Thank You!
API-driven Cloud
Native Solutions
BITS Pilani Dr. Shreyas Rao
Pilani Campus Associate Prof. (Off Campus), CSIS, BITS-Pilani
BITS Pilani
Pilani Campus

CC ZG506
Lecture No. 12
Contact Session wise Coverage

Session Coverage

CS01 API Basics (OpenAPI, REST, gRPC, GraphQL)


CS02 API Basics + Cloud Native Application Basics
CS03 Cloud Native Application
CS04 Introduction to Data Science & Machine Learning, DataOps & Data
MLOps
Science
CS05 API driven Cloud-native Data Pipeline
CS06 API-driven ML pipelines
& ML
CS07 Tools review
CS08 Basic APIs for AI Applications – NLP, CV, Speech recognition Cognitive
CS09 Language Models (LLMs) AI
CS10 Fine Tuning + RAG Models
CS11 RAG Models
CS12 Cloud Native Application Deployment
CS13 IoT and Data Analytics IoT
CS14 APIs for IoT and Data Analytics
CS15 Serverless Functions; Case study
CS16 Course review and discussion

BITS Pilani, Pilani Campus


Agenda

Part-C: Cloud Native Application Deployment


Containers
Dockers
Kubernetes
Deployment Strategies
Demos

BITS Pilani, Pilani Campus


Singer Analogy

A Singer is invited
A Singer forfor
is invited a a
01 concert.
concert. He
He goes
goes there
there and
and
MikeMike
doesdoes
not work
not work

Singer is invited to second


02 concert, where Speakers do
not work

Singer now invests in his own mike


03 and speakers, and takes them to
whichever concert he goes.

This way the vagaries of the environment


(mike, speaker) are avoided

BITS Pilani, Pilani Campus


What are Containers
A software container is a standardized package of software
Everything needed for the software to run is inside the container
The software code, runtime, system libraries, and settings are all inside a single
container
Container based deployments is favoured for Microservices

Cloud Native Development


[Link] Architectural Style
[Link] for Deployment
[Link]
[Link]

BITS Pilani, Pilani Campus


Containers – Build, Ship, Run
Any App Anywhere

BITS Pilani, Pilani Campus


Docker
Is a popular Container technology
It is lightweight, portable and self-sufficient container

BITS Pilani, Pilani Campus


Docker - Container to Package
Software

Dependencie
s

Application
Binarie Bundle
s

Code

BITS Pilani, Pilani Campus


Containers vs Virtual
Machines

BITS Pilani, Pilani Campus


Basic Definitions

• Docker - It is a way to package Software so that it runs on any hardware (OS &
hardware).
• Requires knowledge of three things – dockerfile, images and containers.
a. Docker File - Blueprint for building a Docker Image. Set of Instructions
b. Docker Image - Template for running Docker Containers. Docker image is a
lightweight, standalone, and executable package that includes everything needed to run
a piece of software, including the code, runtime, libraries, and system tools.
c. Docker Container - A docker container is a portable unit of software - that has the
application, along with the associated dependency and configuration. It is running
process of the image. May include Application (Web - [Link]) and Database
(DB - MySQL). One image file can be made to spawn multiple processes across
environments.

BITS Pilani, Pilani Campus


Docker

Step 1: Dockerfile

Step 2: Build Image


[docker build]

Step 3: Run Image as Container


[docker run]

BITS Pilani, Pilani Campus


Purpose of Docker

Reproduce the environment in Development, Staging and Production.


We can define the environment with the Docker File.
People can use the dockerfile to create an image. Images can be uploaded to
Cloud (public or private) repositories using “docker push” command and
pulled using “docker pull” command from the repository.

BITS Pilani, Pilani Campus


Docker Architecture

BITS Pilani, Pilani Campus


Docker Desktop

Docker Desktop is a one-click-install application for Mac, Linux, or Windows


environment that enables you to build and share containerized applications and
microservices.
It provides a straightforward GUI (Graphical User Interface) that lets you manage your
containers, applications, and images directly from your machine.

BITS Pilani, Pilani Campus


Docker Hub

Docker Hub is the world's largest library and community for container images
Contains Official Images for MongoDB, NodeJS, Redis, Ubuntu, Python, MySQL etc.
URL - [Link]

BITS Pilani, Pilani Campus


Example for running a Docker
Container

BITS Pilani, Pilani Campus


Dockerfile

Dockerfile is a text file, named Dockerfile, that includes specific keywords that
dictate how to build a specific image.
Keywords are:

BITS Pilani, Pilani Campus


Docker - Example
DOCKERFILE
FROM ubuntu:latest
RUN mkdir /vim
RUN apt update
RUN apt install vim -y
WORKDIR /vim
ENTRYPOINT ["/bin/bash"]

docker build

IMAGE

docker run

CONTAINER

BITS Pilani, Pilani Campus


Docker Demo

File: “Docker Basics - Docker Desktop and DockerHub”

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

KUBERNETES
Kubernetes / K8s

• Kubernetes is a container orchestration tool that manages applications/ services


available on a container platform like Docker

• Developed by Google labs and later donated to CNCF (Cloud Native Computing
Foundation).

• First CNCF project to graduate

• Open source

• Written in Golang

BITS Pilani, Pilani Campus


Evolution of Deployment

BITS Pilani, Pilani Campus


Features of Kubernetes
(Container Orchestrators)

1. High Availability or No downtime


2. Scalability or High Performance
3. Disaster Recovery – Backup and Restore

BITS Pilani, Pilani Campus


Kubernetes Components

Kubectl

Worker Nodes

BITS Pilani, Pilani Campus


Kubernetes Components

Node

Pods are the smallest deployable units of computing that you can create and
manage in Kubernetes.
A Pod is a group of one or more containers, with shared storage and
network resources

BITS Pilani, Pilani Campus


Kubernetes Cluster

Control Plane nodes are also called as ‘Master Nodes’

BITS Pilani, Pilani Campus


Kubernetes Architecture

BITS Pilani, Pilani Campus


Scheduler – Schedules Pods on
Cluster nodes

BITS Pilani, Pilani Campus


Kubernetes Components

Master Node: The master node (Control Plane Node) is responsible for managing the entire cluster. It
contains various components like the API server, etcd, controller manager, and scheduler.
Worker Nodes: These are the nodes where containers run. They are responsible for running the
application workload and communicating with the master node.
Pods: Pods are the smallest deployable units in Kubernetes. They are used to encapsulate one or more
containers and share storage and network resources.
Services: Services are used to expose a group of pods to the network. They provide a stable IP address
and DNS name that other services and pods can use to communicate with the group of pods.
Controllers: Controllers are used to manage the lifecycle of pods and services. They ensure that the
desired number of replicas of a pod or service are running and will automatically create or delete pods
as necessary.

BITS Pilani, Pilani Campus


Master Node Components

API Server: The API server is the central control point for the Kubernetes cluster. It exposes the
Kubernetes API, which is used by other components to communicate with the cluster. It stores the
state of the cluster in etcd.
etcd: etcd is a distributed key-value store that stores the configuration data of the Kubernetes cluster. It is
the source of truth for the current state of the cluster and is used by the API server, controller manager,
and scheduler.
Controller Manager: The controller manager is responsible for running the various controllers that regulate
the state of the cluster. For example, the ReplicaSet controller ensures that the desired number of pod
replicas are running, and the Deployment controller manages rolling updates of deployments.
Scheduler: The scheduler is responsible for assigning pods to nodes in the cluster. It takes into account
factors such as resource requirements, node availability, and user-defined policies.

BITS Pilani, Pilani Campus


How Deployment works in Kubernetes

Kubectl - The Kubernetes command-line tool, kubectl, allows you to run commands
against Kubernetes clusters. You can use kubectl to deploy applications, inspect
and manage cluster resources, and view logs.
Kubelet – Manages the state of the node and ensures that containers are running
and healthy. It also monitors the state of the containers and restarts them if they
fail.
Kube-proxy - Manages network connectivity to and from the Pods

[Link]

BITS Pilani, Pilani Campus


Minikube

Is a Single Node Kubernetes cluster, which we can create on local machine


Helps in development and experimentation
Can be run inside of a Container (Docker) or Virtual Machine

[Link]

BITS Pilani, Pilani Campus


Minikube Architecture

Docker
Desktop

Container or virtual machine manager, such as: Docker, QEMU, Hyperkit,


Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation

BITS Pilani, Pilani Campus


Minikube Architecture

BITS Pilani, Pilani Campus


Layers of Abstraction in Kubernetes

Deployment
Template for creating
pods in YAML file

BITS Pilani, Pilani Campus


Basic YAML – Deployment File
Pod Deployment
apiVersion: v1 apiVersion: apps/v1
kind: Pod kind: Deployment
metadata: metadata:
name: my-pod name: my-deployment
spec: spec:
containers: replicas: 2
specify the Pod's
- name: my-cont template:
metadata and
image: nginx:latest metadata:
containers.
labels:
app: my-app
To apply this YAML file to your to manage and
spec:
Kubernetes cluster, you can select resources,
use the kubectl apply containers:
such as in Services
command: - name: my-cont
or ReplicaSets.
kubectl apply -f pod- image: nginx:latest
[Link]

BITS Pilani, Pilani Campus


YAML Configuration File in
Kubernetes
Three parts of Configuration File: apiVersion: apps/v1
[Link] [Mentioned in config file] kind: Deployment
metadata:
[Link] [Mentioned in config file]
name: my-deployment
[Link] [Not present in Config file] spec:
Automatically generated and added by Kubernetes replicas: 2
template:
Matches Desired state vs Actual State
metadata:
[Ex: 2 replicas mentioned in config file (desired) vs 1 replica labels:
running (actual)] -> Self-Healing feature app: my-app
spec:
‘etcd’ component holds the current state of kubernetes
containers:
cluster, which is displayed by Status - name: my-cont
image: nginx:latest

BITS Pilani, Pilani Campus


Kubernetes Dashboard

View the created application in Minikube dashboard

Command: minikube dashboard

See ‘Deployments’, ‘Pods’, ‘Replica Sets’, ‘services’, and view their metadata

BITS Pilani, Pilani Campus


Kubernetes Demo

File: “Kubernetes Basics - MiniKube”

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Deployment Strategies
[Theory Only]
Deployment Strategies

Zero-Downtime Releases
Strategies that organisations use in production to ensure Zero-downtime
deployments.
Also known as hot deployment, is one in which the actual process of switching
users from one release to another happens nearly instantaneously.
[Link]
[Link]
[Link]/Green
[Link]

BITS Pilani, Pilani Campus


1. Basic Deployment

In a basic deployment, all nodes within a target environment are updated at the same time with a
new service or artifact version. Because of this, basic deployments are not outage-proof and they
slow down rollback processes or strategies. [Preferable for very small applications / services]

[Link]

BITS Pilani, Pilani Campus


2. Ramped (also known as
rolling-update or incremental)
This deployment slowly replaces one node at a time to avoid downtime.
Version 2 is slowly rolled out and replaces version 1
Default deployment strategy in Kubernetes

BITS Pilani, Pilani Campus


2. Ramped (also known as
rolling-update or incremental)
• Updates running instances of an application with the new release. All nodes in a target
environment are incrementally updated with the service

Pros
• The benefits of a rolling deployment are that it is relatively simple to roll back, less risky
than a basic deployment

Cons
• Since nodes are updated in batches, rolling deployments require services to support both
new and old versions of an artifact.
• Verification of an application deployment at every incremental change also makes this
deployment slow.

BITS Pilani, Pilani Campus


3. Blue / Green

In this you release a new version of your application or workflow while your current version is
still running.
Version 2 is released alongside version 1, then the traffic is switched to version 2.

BITS Pilani, Pilani Campus


3. Blue / Green – Why the name?

Utilizes two identical environments, a “blue” (aka staging) and a “green” (aka production) environment with
different versions of an application or service. Quality assurance and user acceptance testing are
typically done within the blue environment that hosts new versions or changes. User traffic is shifted from
the green environment to the blue environment once new changes have been tested and accepted
within the blue environment.

BITS Pilani, Pilani Campus


3. Blue / Green

Pros
•It is simple, fast, well-understood, and easy to implement.
•Rollback is also straightforward, because you can simply flip traffic back to the old
environment in case of any issues.
•Blue-green deployments are therefore not as risky compared to other deployment strategies

Cons
•Cost is a drawback to blue-green deployments. Replicating a production environment can
be complex and expensive, especially when working with microservices.
•Quality assurance and user acceptance testing may not identify all of the anomalies or
regressions either, and so shifting all user traffic at once can present risks

BITS Pilani, Pilani Campus


4. Canary

Allow the customers to test your deployment by releasing the new version to a small group of
them.
Version 2 is released to a subset of users, then proceed to a full rollout.
Ex: Facebook release of a new feature only to Asia Pacific region; if successful, then role out to
other regions

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Demo
Demo I

How to dockerize and run a typical “Machine Learning” project?


The ML project (code + ops) needs to be containerized
The prediction should be available via an API endpoint, so that any end-user can
make predictions on the ML model.

BITS Pilani, Pilani Campus


Demo

FastAPI: Defines a prediction API using a POST endpoint that takes input data, preprocesses it, makes a
prediction using a trained model, and logs metrics to MLflow. Runs at localhost:8000 port.

MLflow: Configured as a tracking server accessible at [Link] to log model parameters,


metrics, and artifacts, allowing the FastAPI app to record and monitor model performance.

Dockerfile: Sets up the environment by installing dependencies from [Link], copies the application
files, and configures Uvicorn to serve the FastAPI app on port 8000.

Docker Compose: Orchestrates multi-container deployment with FastAPI and MLflow services, specifying
network configurations and inter-service dependencies to enable seamless communication between
FastAPI and MLflow.

Folder – “MLFlow_Covid_FastAPI-Endpoint_ImageDeployment”

BITS Pilani, Pilani Campus


[Link] file

2 services (fastapi, mlflow)

fastapi needs to build from Dockerfile (build: .) and expose port 8000

mlflow uses a prebuilt image and exposes port 5000

fastapi depends_on mlflow (starts after mlflow)

BITS Pilani, Pilani Campus


Demo II

Dockerize a Fine-Tuned Model available on Open AI

my_openai_ml_app/
|-- [Link] # FastAPI or Flask app for serving predictions
|-- dockerfile # Docker configuration
|-- [Link] # Dependencies
|-- .env # Environment variables (optional)

Code -> “FineTunedModel-Dockerize”


BITS Pilani, Pilani Campus
Dockerizing a RAG Model

Code will have three parts:


[Link] Component: A vector store (e.g., rag_project/
|-- [Link]
FAISS, Elasticsearch) that indexes and
|-- [Link]
retrieves relevant documents. |-- [Link] # FastAPI app
[Link] Component: A language model |-- dockerfile
|-- [Link] # Dependencies
(e.g., OpenAI GPT-4 or other LLMs) that |-- .env # Env variables
processes the retrieved documents and
generates a response.
[Link] Wrapper: An application (e.g., FastAPI
or Flask) that handles user inputs and
orchestrates the RAG workflow.

BITS Pilani, Pilani Campus


Thank
You!
API-driven Cloud
Native Solutions
BITS Pilani Dr. Shreyas Rao
Pilani Campus Associate Prof. (Off Campus), CSIS, BITS-Pilani
BITS Pilani
Pilani Campus

CC ZG506
Lecture No. 13
Contact Session wise Coverage

Session Coverage

CS01 API Basics (OpenAPI, REST, gRPC, GraphQL)


CS02 API Basics + Cloud Native Application Basics
CS03 Cloud Native Application
CS04 Introduction to Data Science & Machine Learning, DataOps & Data
MLOps
Science
CS05 API driven Cloud-native Data Pipeline
CS06 API-driven ML pipelines
& ML
CS07 Tools review
CS08 Basic APIs for AI Applications – NLP, CV, Speech recognition Cognitive
CS09 Language Models (LLMs) AI
CS10 Fine Tuning + RAG Models
CS11 RAG Models
CS12 Cloud Native Application Deployment
CS13 IoT and Data Analytics IoT
CS14 APIs for IoT and Data Analytics
CS15 Serverless Functions; Case study
CS16 Course review and discussion

BITS Pilani, Pilani Campus


Agenda

Data Analytics
Overview of Data Analytics
Types of Data Analytics

BITS Pilani, Pilani Campus


BITS Pilani
Pilani Campus

Data Analytics
Data Analytics

Data analytics is defined as a process of cleaning, transforming, and modeling


data to discover useful information for business decision-making.

4 different types of analytics


[Link] Analytics
[Link] Analytics
[Link] Analytics
[Link] Analytics

BITS Pilani, Pilani Campus


Data Analytics

BITS Pilani, Pilani Campus


Goals of Data Analytics
To predict something
• whether a transaction is a fraud or not [Banking]
• whether it will rain on a particular day [Weather Forecast]
• whether a tumor is benign or malignant [Cancer Prediction, Healthcare]
To find patterns in the data
• finding the top 10 coldest days in the year [Weather Forecast]
• which pages are visited the most on a particular website [Web Traffic Rank]
• finding the most searched celebrity in a particular year [Awards]
To find relationships in the data
• finding similar news articles [Bing, Google]
• finding similar patients in an electronic health record system [Healthcare]
• finding related products on an e-commerce website [Recommendation]
• finding correlation between news items and stock prices

BITS Pilani, Pilani Campus


Descriptive Analytics

Answers the question of what happened.


Summarize past data usually in the form of dashboards.
Insights into the past.
Also known as statistical analysis.
Raw data from multiple data sources.

BITS Pilani, Pilani Campus


Descriptive Analytics Example-I

BITS Pilani, Pilani Campus


Descriptive Analytics Example-II

Paper - Healthcare Delivery through Telemedicine during the COVID-19 Pandemic: Case Study from a Tertiary Care Center in South India
[Link]

BITS Pilani, Pilani Campus


Descriptive Analytics Techniques

Techniques

•Descriptive Statistics - histogram, correlation


•Data Visualization
•Exploratory Analysis [Seaborn Library in Python]

BITS Pilani, Pilani Campus


Diagnostic Analytics

Answers the question of why something happened.


Gives in-depth insights into data.
Identify relationship between data and identify patterns of behavior.
Diagnostic analytics is a form of data analytics that builds on descriptive analytics to
help you understand why something happened in the past.

Often, diagnostic analysis is referred to as root cause analysis. It involves


processes such as data discovery, data mining, and drill down and drill through.

BITS Pilani, Pilani Campus


Diagnostic Analytics Example
What is the effect of global warming in the Southwest monsoon?

BITS Pilani, Pilani Campus


Diagnostic Analytics Techniques

Pattern recognition to identify patterns.


Linear / Logistic regression to identify relationship.
Neural Network
Deep Learning techniques

BITS Pilani, Pilani Campus


Predictive Analytics

Answers the question of what is likely to happen.


Predict future trends.
Being able to predict allows one to make better decisions.
Analysis based on machine or deep learning.
Accuracy of the forecasting or prediction highly depends on data quality and
stability of the situation.

BITS Pilani, Pilani Campus


Predictive Analytics Techniques

Techniques / Algorithms:
•Regression
•Classification
•ML algorithms like Linear regression, Logistic regression, SVM
•Deep Learning techniques

BITS Pilani, Pilani Campus


Predictive Analytics Example

Covid Patient Discharge Prediction (Dataset: 2nd Wave April-2021 to June 2021)
Type of Project: Machine Learning
Dataset size: 1233 patients suffering from Covid
Variables:
X: Age, Gender, Co_morbid, Admit Date, Discharge date, days of stay,
covid_severity
Y: Discharge Type (Recovered, Expired)
Exploratory Data Analysis: Univariate, Bivariate, Multivariate
Models applied: Support Vector Machine, Naïve Bayes, Logistic Regression,
Decision Trees, KNN, ANN, Random Forest
Best Accuracy: Random Forest (92%)

BITS Pilani, Pilani Campus


Prescriptive Analytics

Answers the question of what might happen.

Data-driven decision making and corrective actions


Prescribe what action to take to eliminate a future problem or take full
advantage of a promising trend.
Need historical internal data and external information like trends.
Analysis based on machine or deep learning, business rules.

Use of AI to improve decision making.

BITS Pilani, Pilani Campus


Prescriptive Analytics Example - I

Apollo Hospitals uses an AI tool to predict the risk of cardiovascular disease.


The Apollo AI-powered “Cardiovascular Disease Risk” tool will help healthcare
providers to predict the risk of cardiac disease in their patients [Predictive
Analytics]
The prediction initiates intervention early enough to make a real difference.
[Prescriptive]
The cardiac risk scoring tool is remarkable for the speed in processing data and its
accuracy at predicting the probability of a patient developing coronary disease.
Using the tool, physicians will be enabled to deliver proactive, pre-emptive and
preventive care for at-risk individuals, improving lives, while mitigating future
pressure on healthcare systems.

BITS Pilani, Pilani Campus


Prescriptive Analytics Example - II
How can we improve the crop production?

BITS Pilani, Pilani Campus


Types of Data Analytics

BITS Pilani, Pilani Campus


Types of Data Analytics
Exercise

Instagram Reels allows users to create fun videos and share with their contacts.
Users can record 15 second multi-clip videos with audio and effects. Some
features include: exploring reels based on subject; following, commenting and
liking a reel; identifying trends to create new reels. The reels are released in two
versions – public (free for all), and premium (subscription basis).

 Discuss the four analytical tasks that can be performed with respect to the
Instagram Reels? [Descriptive, Diagnostic, Predictive and Prescriptive]

BITS Pilani, Pilani Campus


Types of Data Analytics

Instagram Reels

Descriptive - How many followers do you have, how many views, comments,
likes for your video [free], audience breakdown by country, follower activity per
hour [premium]

Diagnostic - Why your video’s engagement rate is less. [premium users]

Predictive - Trending topics for you to make video on - their approximate


engagement rates [premium]

Prescriptive - Tips to increase average watch time of your videos [premium]

BITS Pilani, Pilani Campus


Cognitive Analytics
Cognitive Analytics – What I Don’t Know?

BITS Pilani, Pilani Campus


Cognitive Analytics

• Next level of Analytics


• Human cognition is based on the context and reasoning.
• Cognitive systems mimic how humans reason and process.
• Cognitive systems analyze information and draw inferences using probability.
• They continuously learn from data and reprogram themselves.

Definition according to one source:


”The essential distinction between cognitive platforms and artificial intelligence
systems is that you want an AI to do something for you. A cognitive platform is
something you turn to for collaboration or for advice.”

BITS Pilani, Pilani Campus


Cognitive Analytics
Involves Semantics, AI, Machine learning,
Deep Learning, Natural Language
Processing, and Neural Networks.
Simulates human thought process to learn
from the data and extract the hidden
patterns from data.
Uses all types of data: audio, video, text,
images in the analytics process.
Although this is the top tier of analytics
maturity, Cognitive Analytics can be
used in the prior levels.
According to Jean Francois Puget:
”It extends the analytics journey to areas
that were unreachable with more
classical analytics techniques like
business intelligence, statistics, and
operations research.”

BITS Pilani, Pilani Campus


Example

Woebot Mental Health App

•Provides mental health support, using Cognitive Behavioral Therapy (CBT)


•NLP based self-learning App that advises / chats with users on mental health, developed by
Stanford University

Category: Conversational AI for Therapy: Woebot applies principles from cognitive analytics and
predictive models to shape responses, but its primary function is to provide therapeutic support
through guided conversation.

Benefits:
•Using Woebot led to significant reductions in anxiety and depression among people aged 18-
28 years old, compared to an information-only control group.
•85% of participants used Woebot on a daily or almost daily basis.
BITS Pilani, Pilani Campus
Cognitive Analytics

Healthcare Diagnosis and Treatment Recommendation

•How it's used: Cognitive analytics systems like IBM Watson Health analyze patient
records, genetic information, research papers, and clinical trials to suggest
personalized treatment options.

•Example: Helping doctors detect diseases like cancer early by identifying subtle
patterns in MRI scans and medical history.

BITS Pilani, Pilani Campus


Cognitive Analytics

Customer Service Chatbots and Virtual Assistants

•How it's used: Cognitive systems power chatbots that can understand customer
emotions and context to respond more intelligently.

•Example: Virtual agents like Amelia or IBM Watson Assistant resolve queries,
escalate complex cases, and even offer personalized product recommendations.

BITS Pilani, Pilani Campus


Cognitive Analytics

Predictive Maintenance in Manufacturing

•How it's used: Cognitive systems analyze sensor data from machines to predict
equipment failures before they happen.

•Example: GE and Siemens use cognitive analytics to reduce downtime and


optimize maintenance schedules in industries like aviation and power generation.

BITS Pilani, Pilani Campus


Thank
You!

You might also like