AI-900-3,4



Module : 3 Get Started with Machine Learning in Azure

Machine learning drives today’s AI by turning data into insights for predictions and recommendations.



Creating an ML solution requires key decisions that affect cost, speed, and quality. Using Microsoft Azure, the process follows six main steps:

Define the Problem: Decide what to predict and how to measure success.

Get the Data: Find and access reliable data sources.

Prepare the Data: Clean, explore, and format the data for modeling.

Train the Model: Choose algorithms and adjust parameters.

Integrate the Model: Deploy it to generate predictions.

Monitor the Model: Track performance and retrain as needed.

Machine learning is an ongoing process. Models evolve as data changes.


Step 1: Define the Problem



The first step in building a machine learning (ML) solution is to define the problem. You need to clearly understand what you want the model to predict and how you will measure success.

Key Considerations

Model output: What result should the model produce?

ML task type: What kind of prediction or insight do you need?

Success criteria: How will you measure performance, like accuracy or precision?


Common Machine Learning Tasks

Classification: Predict categories, like spam or not spam.

Regression: Predict numerical values, such as house prices.

Time-series forecasting: Predict future values over time.

Computer vision: Identify or classify objects in images.

Natural Language Processing (NLP): Extract meaning from text.


Example: Detecting Diabetes




Goal: Predict whether a patient has diabetes, either Yes or No.

Data: Patient health metrics.

Task type: Classification, which has a categorical output.


Model Development Steps

Load data: Import and explore the dataset.

Preprocess data: Clean and normalize for consistency.

Split data: Divide into training and test sets.

Choose model: Select and configure an algorithm.

Train model: Learn from the training data.

Score model: Predict using the test data.

Evaluate: Measure performance with metrics.


Training is iterative. You may need to repeat steps to get the best model performance.


Step 2: Get and Prepare Data

Data is the base of machine learning. Its quality and quantity directly impact model accuracy.

To train a model effectively, you need to:




Identify data sources and formats

Sources may include CRM systems, SQL databases, or IoT devices.

Data formats can be structured (tables), semi-structured (JSON), or unstructured (text, images).

Design a data ingestion solution

Extract data from its source.

Transform and load it into a serving layer for analysis or training.

This process is called ETL (Extract, Transform, Load) or ELT (Extract, Load, Transform).

Build a data ingestion pipeline

Automate data movement and transformation.

Tools: Azure Synapse Analytics, Azure Databricks, Azure Machine Learning.


Example: Weather Forecasting Model




Source: IoT devices recording temperature data in JSON format.

Process:

Extract JSON data.

Convert it into tabular form.

Aggregate average temperatures per hour.

Result: A clean dataset ready for model training in Azure ML.

Well-prepared data ensures higher model accuracy and smoother training.



Step 3: Train the Model

After preparing your data, the next step is to train your machine learning model. The service you select will depend on several factors:

- The type of model you need

- How much control you want over training

- The time and resources you have

- Your preferred programming language

- Your organization’s existing tools


Azure Services for Model Training

Azure Machine Learning: This is a complete platform for building, training, and managing ML models. It offers both a user interface (Studio) and a code-first approach (Python SDK/CLI).

Azure Databricks: A Spark-based platform for processing large data sets and training models. It can work with Azure ML for deployment.

Microsoft Fabric: This platform brings together analytics where you can prepare data, train models, and visualize results in Power BI.

Azure AI Services: These are ready-to-use APIs for common ML tasks like object detection or text analysis, with options to customize them using your own data.

Azure Machine Learning Capabilities


Azure Machine Learning allows you to:

- Explore and prepare data

- Train and evaluate models efficiently

- Register, manage, and deploy trained models

- Use AutoML to automatically find the best-performing model

- Integrate with ML frameworks like MLflow for scalable workflow management

- Use Responsible AI tools for fairness, explainability, and transparency


Azure Machine Learning offers compute power, automation, and built-in visualization tools to streamline the entire model training process.


Step 4: Use Azure Machine Learning Studio

Azure Machine Learning Studio is a browser-based portal that allows you to manage and run all your machine learning workflows in one place. There is no need for local installations.


What You Can Do in Azure ML Studio

- Import, explore, and prepare data.

- Create and manage compute resources.

- Run notebooks or use visual drag-and-drop tools.

- Use Automated ML to train models without writing code.

- View detailed metrics, responsible AI insights, and training parameters.

- Deploy trained models for real-time or batch inferencing.

- Access a model catalog to import or manage models.




Provisioning Azure ML Resources

Start by creating an Azure Machine Learning workspace in your Azure subscription. Azure will automatically create supporting resources like storage accounts, container registries, and compute clusters as needed.


Choosing Compute Options

Compute refers to the processing power used to train models.

- CPU: Best for small, tabular datasets; cost-effective.

- GPU: Ideal for images, text, or large datasets; offers faster performance.

- General Purpose: Balanced CPU-to-memory ratio; good for testing.

- Memory Optimized: High memory capacity for large datasets.


Monitor compute usage and adjust resources for optimal performance. Use distributed computing like Spark for large-scale training.

Azure Automated Machine Learning (AutoML)

AutoML automates the training and tuning process, selecting the best algorithms and parameters for you.

No coding is required; just follow a step-by-step wizard.

It supports tasks like classification, regression, forecasting, computer vision, and natural language processing.

AutoML automatically provisions compute and deploys the trained model as a service.

Azure ML Studio simplifies end-to-end machine learning, from data to deployment.


Step 5: Integrate the Model

After training, the next step is to integrate and deploy your machine learning model so it can make predictions. You deploy the model to an endpoint. This endpoint acts like a web address an application can call to receive predictions.


Types of Model Deployment

Real-time Predictions

These are used when results are needed instantly.

Example: A website recommending related products as soon as a user clicks an item.

Best for apps or systems that require immediate responses.



Batch Predictions

These are used when predictions can be generated periodically or in bulk.

Example: Forecasting weekly sales or analyzing customer churn once per month.

Ideal when results aren’t needed right away.



Choosing Between Real-time and Batch

Ask yourself:

How often are predictions required?

How quickly should results be available?

Are predictions made one-by-one or in groups?

What compute resources and cost can you support?


Real-time means instant insights; this requires always-on compute.  

Batch means scheduled scoring; this is cost-effective and scalable on demand.


Compute Considerations

Real-time uses always-on compute via Azure Container Instances (ACI) or Azure Kubernetes Service (AKS). This is faster but more costly.

Batch uses compute clusters that scale up for processing and scale down when idle. This is efficient and budget-friendly.


Example

Predict customer churn:

Individual mode: One customer at a time.

Batch mode: Many customers at once (returns a full results table).


Choosing the right integration method ensures your model performs well, meets business needs, and optimizes cost.


Module : 4 Introduction to Generative AI and agents

Large Language Models (LLMs) :

What are LLMs?
- They form the core of generative AI. There are also smaller versions called SLMs (Small Language Models).
- LLMs capture linguistic and semantic relationships between words and phrases.
- They generate meaningful responses based on prompts, similar to the predictive text feature on phones.


How LLMs Work?
- Tokenization
Text is divided into tokens: words, subwords, punctuation, and common character sequences.
Each token receives a unique ID.
For example, “I heard a dog bark” becomes tokens [I, heard, a, dog, bark] with IDs [1, 2, 3, 4, 5].


- Vector Representation (Embeddings)
Each token is assigned a vector, which is an array of numeric values.
Initial vectors are random. Transformer models refine them to capture linguistic and semantic meaning.
Contextualized embeddings help the model understand relationships like "dog" being similar to "puppy" or "bark" (dog) not being the same as "bark" (tree).
dog ~ puppy and bark(dog) != bark(tree).

- Transformer Architecture
The encoder creates embeddings by weighing the influence of tokens in context. Multi-head attention helps improve efficiency.
The decoder predicts the next token in a sequence using embeddings and attention.
Positional encoding helps track the order of tokens.



- Attention & Context
Tokens that influence others more strongly receive higher weights.
Multi-head attention captures multiple relationships at once.
Embeddings are vectors in multi-dimensional space; similar meanings mean vectors point in similar directions.

- Predicting Completions
The decoder predicts the next token based on the previous tokens, using masked attention during training.
For example, “When my dog was a …” leads to predicting “puppy” as the most likely next token.
This process continues until the sequence ends.

Key Takeaways
LLMs understand context, semantics, and syntax through embeddings and attention mechanisms.
Embeddings allow for measuring semantic similarity, such as cosine similarity.
The effectiveness of generative AI is mathematical, not mystical; it is essentially about recognizing patterns on a large scale.


Step 6: Prompts in Generative AI

A prompt is what you provide to a large language model (LLM) to get a response. It can be a question, a command, or a casual statement. The model then gives a completion.

- Types of Prompts



- System Prompts: These set the behavior, tone, and limits of the model.
Example: "You're a helpful assistant that responds in a cheerful, friendly manner."

- User Prompts: These ask the model a specific question or give an instruction.
Example: "Summarize key considerations for adopting Generative AI in six bullet points with a professional tone."

- Conversation History
    Generative AI apps often keep track of conversation history to provide context.



    Summarized past prompts and responses are included in new prompts. This ensures the model gives coherent and relevant answers.

- Retrieval-Augmented Generation (RAG)
RAG enhances prompts with external information, like documents or emails.



Example: When asking about travel expenses, the model can pull in relevant policy data from company documents. This gives a contextual and accurate response.

- Tips for Better Prompts



Be clear and specific: Steer clear of vague instructions.
Add context: Include topic, audience, or format.
Use examples: Show the desired style or format.
Ask for structure: Mention bullet points, tables, or lists.

Well-designed prompts significantly improve the quality and relevance of AI responses.



Step 7: AI Agents

AI agents are digital assistants based on generative AI. They don’t just answer questions; they can think, act, and automate tasks.

- Components of an AI Agent



Large Language Model (LLM): This is the agent’s "brain" for understanding language and reasoning.
Instructions: These are system prompts that define the agent’s role and behavior.
Tools: These help the agent interact with the world:
    Knowledge tools: Access information from databases or search engines.
    Action tools: Perform tasks like sending emails, updating calendars, or controlling devices.

- Multi-Agent Systems
Multiple AI agents can work together, each with a specialized role.



Example: One agent gathers data, another analyzes it, and a third takes action.
Agents communicate through prompts, coordinating tasks like a human team. They form an AI-powered workforce.

Agentic AI represents the next step in using AI to find information, automate workflows, and boost productivity.




Comments

Popular posts from this blog

AI-900 12,13

AI-900 10,11