Share
Explore

Building the AI Model : Test Questions Bank

August 2
Table 1
Question
Correct Answer
Answer 1
Answer 2
Answer 3
Answer 4
Column 7
Explanation
Explanation 2
1
In the conceptual model for AI language models, which layer receives raw text?
1
Input Layer
Embedding Layer
Encoder Layer
Output Layer
Output Layer
The Input Layer is responsible for receiving raw text in the conceptual model.
The Input Layer is responsible for receiving raw text in the conceptual model.
2
What does the Embedding Layer do in an AI language model?
2
Generate output text
Convert words to numerical vectors
Extract patterns
Produce final text prediction
Produce final text prediction
The Embedding Layer converts words to numerical vectors, allowing the model to process text mathematically.
The Embedding Layer converts words to numerical vectors, allowing the model to process text mathematically.
3
Which layers are responsible for extracting patterns and relationships in the text?
3
Input Layers
Embedding Layers
Encoder Layers
Output Layers
Output Layers
Encoder Layers are responsible for extracting patterns and relationships from the input text.
Encoder Layers are responsible for extracting patterns and relationships from the input text.
4
In the provided code example, what type of neural network layer is used for the encoder and decoder?
3
Dense
Embedding
LSTM
Convolutional
Convolutional
The code example uses LSTM (Long Short-Term Memory) layers for both the encoder and decoder.
The code example uses LSTM (Long Short-Term Memory) layers for both the encoder and decoder.
5
What is the purpose of the output layer in the LanguageModel class?
4
Receive input
Generate embeddings
Process sequences
Produce final text prediction
Produce final text prediction
The output layer (Dense layer) in the LanguageModel class produces the final text prediction.
The output layer (Dense layer) in the LanguageModel class produces the final text prediction.
6
How is modular design in AI language models similar to Java programming?
1
Each layer is a self-contained unit
Layers are written in Java
Models use Java Virtual Machine
AI models are objects
AI models are objects
Modular design in AI models is similar to Java as each layer is a self-contained unit with a specific purpose, like Java objects.
Modular design in AI models is similar to Java as each layer is a self-contained unit with a specific purpose, like Java objects.
7
How does data flow in an AI language model compare to Java object interactions?
3
Through SQL queries
Via HTTP requests
Through the layers, similar to method calls
Using global variables
Using global variables
Data flows through the layers in AI models, similar to method calls between Java objects.
Data flows through the layers in AI models, similar to method calls between Java objects.
8
What concept in AI models is analogous to shared fields in Java objects?
1
The model's weights
The input data
The output predictions
The layer names
The layer names
The model's weights are like shared fields in Java objects, updated during training.
The model's weights are like shared fields in Java objects, updated during training.
9
How is the concept of composition applied in AI language models?
1
Layers are composed together to form the complete model
Models are composed of Java classes
Composition is not used in AI models
Models are composed of SQL tables
Models are composed of SQL tables
Layers are composed together to form the complete model, analogous to object composition in Java.
Layers are composed together to form the complete model, analogous to object composition in Java.
10
What OOP concept is similar to how the high-level AI model hides complex internal operations?
3
Inheritance
Polymorphism
Encapsulation
Overloading
Overloading
The high-level model hiding complex internal operations is similar to encapsulation in OOP.
The high-level model hiding complex internal operations is similar to encapsulation in OOP.
11
In the code example, what does the 'embedding_dim' parameter represent?
3
The size of the input vocabulary
The number of encoder layers
The dimension of word embeddings
The batch size for training
The batch size for training
The 'embedding_dim' parameter represents the dimension of word embeddings, determining how words are represented numerically.
The 'embedding_dim' parameter represents the dimension of word embeddings, determining how words are represented numerically.
12
What is the purpose of the 'vocab_size' parameter in the LanguageModel class?
2
To set the number of layers
To determine the size of the input vocabulary
To set the embedding dimension
To set the batch size
To set the batch size
The 'vocab_size' parameter determines the size of the input vocabulary, affecting the input and output layer sizes.
The 'vocab_size' parameter determines the size of the input vocabulary, affecting the input and output layer sizes.
13
Which method in the LanguageModel class is responsible for the forward pass of data?
2
init
call
fit
predict
The 'call' method in the LanguageModel class is responsible for the forward pass of data through the model.
The 'call' method in the LanguageModel class is responsible for the forward pass of data through the model.
14
What type of layer is used for the final output in the LanguageModel class?
3
LSTM
Embedding
Dense
Flatten
A Dense layer is used for the final output in the LanguageModel class.
A Dense layer is used for the final output in the LanguageModel class.
15
How many encoder layers are created in the example LanguageModel initialization?
3
1
2
3
4
The example initializes the LanguageModel with 3 encoder layers (num_layers = 3).
The example initializes the LanguageModel with 3 encoder layers (num_layers = 3).
16
What is the purpose of the 'return_sequences=True' parameter in the encoder LSTM layers?
3
To return the model to initial state
To allow sequences to be input
To output sequences for the next layer
To reverse the input sequence
To reverse the input sequence
The 'return_sequences=True' parameter allows the LSTM layer to output sequences for the next layer, maintaining temporal information.
The 'return_sequences=True' parameter allows the LSTM layer to output sequences for the next layer, maintaining temporal information.
17
Which TensorFlow module is primarily used in the code example?
2
tf.keras
tf.train
tf.estimator
tf.estimator
The code example primarily uses the tf.keras module for building the neural network model.
The code example primarily uses the tf.keras module for building the neural network model.
18
What would be a suitable method name for preprocessing input text in the LanguageModel class?
3
process_input
encode_text
preprocess_text
tokenize_input
tokenize_input
A suitable method name for preprocessing input text would be 'preprocess_text', clearly indicating its purpose.
A suitable method name for preprocessing input text would be 'preprocess_text', clearly indicating its purpose.
19
In the exercise, what functionality is suggested to be added to the LanguageModel class?
3
A method to visualize the model
A method to save the model
A method to generate text given a starting prompt
A method to evaluate the model's performance
A method to evaluate the model's performance
The exercise suggests adding a method to generate text given a starting prompt to the LanguageModel class.
The exercise suggests adding a method to generate text given a starting prompt to the LanguageModel class.
20
How does the conceptual model of AI language models help in understanding the architecture?
1
It provides a visual metaphor similar to Java objects
It explains the mathematical formulas used
It shows the exact TensorFlow implementation
It provides the training data required
It provides the training data required
The conceptual model helps understand AI language model architecture by providing a visual metaphor similar to Java objects, making it easier to grasp for those familiar with OOP concepts.
The conceptual model helps understand AI language model architecture by providing a visual metaphor similar to Java objects, making it easier to grasp for those familiar with OOP concepts.
There are no rows in this table



JULY 30:
megaphone

Describe the key components of the AI application development methodology that we covered in this class, including the use of tools like Trello, Overleaf, and synthetic personalities created with AI assistants. Explain how these elements work together to support the successful delivery of the class project.

The Development of an AI application involves several stages; the mentioned tools help to facilitate the process in every stage. For instance, for project planning:
- A Trello board helps us to manage the project. We can create a list of tasks such as "To do," "In Progress," and "Done."
- Overleaf: This tool helps us create project documentation collaboratively, such as architecture design, research papers, model selection rationale, etc.
- Synthetic personalities: Can help in the data collection, such as synthetic data generation

Train your thinking to lean into / work with the AI agents and personalities you will build to amplify your cognitive scope and bankwidth. In addition to just to answering questions: Ask your AI to advise you on concerns which you SHOULD be thinking about which you have not get thought about.
Exam Question: How does your AI KNOW what you need that you have not yet considered?

ok

Discuss the importance of the video component in the class project, as emphasized by Peter Sigurdson. Explain how creating and presenting a video can help reinforce learning and develop valuable skills for future job interviews and presentations.


You build a short look reward cycle of speaking and presenting knowledgably about these topics and getting a dopamine rush of confidence and encourage which spills over into your other arena.
image.png

Provide a comprehensive overview of the process for building the AI application that you are required to develop for the AML 3304 class, as described in our lectures. Include the following key elements: The software development methodology and tools used, such as the Unified Model Engineering Process, Trello for project management, and Overleaf for the LaTeX presentation document.

The steps involved in constructing the AI model, including the use of Google Colab notebooks, PyTorch, TensorFlow, and potentially deploying the model to platforms like Hugging Face Spaces. The importance of incorporating theoretical concepts and research questions into the project report to demonstrate an understanding of the underlying principles of AI and language models. The role of synthetic personalities created using tools like Claude AI to assist in the development and delivery of the project, including providing guidance and feedback to the students.

Mid Term Review Test Prep:

info

What are the differences between old-school methodologies like Waterfall and Agile compared with Unified Process software development processes? Discuss this in the context of the Software Crisis of the 1970s.


Modern software development methodologies put the User at the Center by gather user stories which is what Unified process does.
Modern software development methodologies are “agile” meaning, we update the plan continually as we acquire new knowledge:
<What kind of knowledge?>
Knowledge of how the Business Domain operates
Knowledge of how our development technology stack tools work: programming languages, database.



What are you giving to OPEN AI in exchange for “free” access?
Training Data.
The analysts say that the big problem with the emerging Chat GPT 5 is: There is not enough data in the world to train next Gen AI?
Synthetic Data: Perry the Stochastic Parrot
The problem with Synthetic Data? “The 2 Irish men problem”

July 12 Attendance Quiz Start of class : AI/ML engineering practices
Feature Engineering Teaching Question: Feature engineering is the process of creating new input features or transforming existing ones to improve model performance.
One common technique is binning, where continuous variables are grouped into discrete categories.
For example, age could be binned into "child", "adult", and "senior".

Q: What is the main purpose of feature binning in machine learning?
A: To convert continuous variables into categorical ones, potentially uncovering non-linear relationships and reducing noise.

CI/CD with GitHub Teaching Question:
Continuous Integration and Continuous Deployment (CI/CD) automate the building, testing, and deployment of code changes.
GitHub Actions allows you to create workflows that automatically run when certain events occur in your repository, like a push or pull request.

In a GitHub Actions workflow, what file extension is used for the configuration file? A: .yml or .yaml
(Yet Another Markup Language)

AI Model Architecture Teaching Question: The architecture of an AI model refers to its structure and components.
In a transformer model, a key component is the self-attention mechanism, which allows the model to weigh the importance of different parts of the input when processing each element.
What is the primary advantage of self-attention in transformer models?
A: It allows the model to consider the context and relationships between all parts of the input sequence.

AI Application Building with Google Colab and Hugging Face Spaces Teaching Question:
Google Colab provides a free Jupyter notebook environment with GPU support, ideal for developing AI models.
Hugging Face Spaces allows easy deployment [Model Serving environment] of these models as web applications. You create Web Route URLs
You can develop a model in Colab, save it, and then upload it to Hugging Face for deployment.

Q: What is a key advantage of using Google Colab for AI model development?
A: Free access to GPU resources for faster training and execution of models.

Transfer Learning in AI Teaching Question:
Transfer learning is a technique where a model trained on one task is repurposed on a second related task.
This approach is particularly useful when you have limited labeled (by features which is your category names) data for your target task.
For example, you might use a model pre-trained on ImageNet to classify a specific type of medical image.

Q: What is the primary benefit of using transfer learning in AI model development?
A: It allows for effective training on smaller datasets by leveraging knowledge from models trained on larger datasets. (You get the benefit of tokens, weightings, and training which someone else paid for).

June 21 Start of Class Attendance Questions:
info

Question 1

What are the key differences between deterministic algorithms and probabilistic algorithms in AI model development?
Expected Answer:
Deterministic algorithms produce the same output given the same input, with predictable and repeatable behavior. Examples include traditional rule-based systems and most classical algorithms.
Probabilistic algorithms incorporate randomness and produce different outcomes given the same input. They model uncertainty and variability in data, making them suitable for tasks like classification, prediction, and decision-making under uncertainty.

Question 2

Explain the importance of the Continuous Integration/Continuous Deployment (CI/CD) pipeline in AI model development.
Expected Answer:
CI/CD pipelines automate the process of integrating code changes, running tests, and deploying applications, ensuring that code is always in a deployable state.
In AI model development, CI/CD facilitates continuous updates and improvements to models, handles version control, and ensures that new models or changes are automatically tested and deployed, reducing errors and speeding up the development process.

Question 3

Describe the role of hyperparameter tuning in building AI models and give an example of a common hyperparameter in neural networks.
Expected Answer:
Hyperparameter tuning involves adjusting the parameters that govern the training process of a model (e.g., learning rate, batch size) to improve performance.
A common hyperparameter in neural networks is the learning rate, which controls how much the model's weights are adjusted with respect to the loss gradient during training. Finding the right learning rate is crucial for effective training and model convergence.

Question 4

What is the purpose of using pre-trained models in AI, and how can they be fine-tuned for specific tasks?
Expected Answer:
Pre-trained models are AI models that have been previously trained on a large dataset and can be used as a starting point for similar tasks. They save time and computational resources by leveraging already learned features and patterns.
Fine-tuning involves taking a pre-trained model and training it further on a specific dataset related to the task at hand, often with a smaller learning rate. This allows the model to adapt to the specific nuances of the new data while retaining the general knowledge from the pre-trained model.

s24 Midterm Exam Study Syllabus


Perry the Stochastic Parrot, Synthetic Training Data, and Making it “realer than real” {Read my LI Blog post}

Software engineering and Software Project management:

Question: Discuss the Architecture of the AI Product



LINK to my Book on UMEP Unified Model Engineering Process:
image.png
megaphone

Here are three short answer quiz questions to assess students' comprehension of the lecture:

1. **Question:** Describe two key differences between the Unified Process (UP) and the proposed Unified Model Engineering Process (UMEP) when it comes to developing AI systems.
**Expected Answer:** - UP is more suited for deterministic algorithms and follows a fixed phase-oriented approach, while UMEP is designed for probabilistic algorithms and emphasizes continuous experimentation and iteration. - UP is structured around predefined requirements and design, whereas UMEP focuses on ongoing data exploration, model validation, and adaptability to changing data and model characteristics.
2. **Question:** Explain why continuous integration and continuous deployment (CI/CD) are crucial in the Unified Model Engineering Process (UMEP) for AI development.
**Expected Answer:** CI/CD is crucial in UMEP because it allows for continuous updates and improvements to the AI models. This is essential for handling the dynamic nature of AI development, where models need frequent retraining and fine-tuning based on new data and performance feedback.
3. **Question:** What are the main phases of the Unified Process (UP), and how do they differ from the phases in the Unified Model Engineering Process (UMEP)?
**Expected Answer:** The main phases of UP are Inception, Elaboration, Construction, and Transition. These phases follow a structured and sequential approach. In contrast, UMEP includes Adaptive Inception, Experimental Elaboration, Iterative Construction, and Dynamic Transition, which focus more on flexibility, continuous experimentation, and adaptation to the evolving nature of AI models and data.

image.png
image.png
Question: Discuss the Build Process for the AI technology Stack
Continous Integration Continuous Development CI CD
megaphone
Concepts to program into your Thinking:
Software Crisis → Lead to : Unified Process and Agile (Goal = Eliminate knowledge silos):
Tools: Traceability Matrix and Daily Agile Stand Up meetings.

The software prices happen because we know why it happened. The outgrowth of the software process, of the software crisis was decision to prevent knowledge siloing by starting our development process by gathering user stories to make sure that our users and our business domain and our code stay in sync throughout the project, we use CICD to get issues and get actions, and we use daily agile stand up meetings to study the traceability matrix and our Git issues to decide how we need to course correct

Transparency, Fairness and freedom Bias in the AI MODEL
Having a diverse range of training data sets.
Emerging job categories in the AI economy: Cognitive Systems Trainer : Having the knowledge of the best sources of training data sets.


Be able to discuss the roles of tokens and weightings in the AI MODEL.

Baysian Models, ANNs and GANs as components of the AI Model Architecture:
Artificial Neural Networks and Generative Adversarial Networks as AI Architectural Layers:


Course PowerPoint on Software Engineering and Build practices for the AI MODEL

Question topics:
You will not be asked to write code, but you may be shown some simple code snippets and asked to provide an analysis of what is going on with it.
What embeddings are. How we make and use them in building the AI MODEL.
The Role of Embeddings in AI Language generation.
Operation of tools (GCN, HuggingSpace, Runpod.io)
Popular libraries for AI Model Building: PyTorch, TensorFlow, NLTK


minus
Unified Model Engineering Process: (Read my book):
The evolution of Unified Process for engineering the AI MODEL.

How did these ways of thinking grow out of the problems and lessons learned from the
Software Crisis: How did it happen / causes and structural elements.

How did we fix that? We invented a bunch of cool stuff:
Agile
Unified Process

Predicted upcoming AI centric software crisis:


AI Models and Business Domains: Why might businesses applying AI models without understanding their business domain lead to a software crisis? How can such a crisis become an opportunity for students and professionals?

Developing the Ai model without understanding the business domain can cause money wastage and poor proformance so this allow student and professional to enter with their knowledge and solve the problem





<Career Advice “The Dad Talk”>

Art of War: The Capacity to Defect other people is provided by them.

The Capacity to be Defeated is provided by me.

Course PowerPOINT:

June 11

megaphone

Key References to the Software Crisis and Unified Process

Software Crisis
Discussion: The software crisis is attributed to treating software development like civil engineering, which led to inefficiencies and poor project management. The crisis highlighted the need for better methodologies as software development projects struggled with cost, schedule, and quality issues.
Citation: "The Software Crisis happen because people tried to make software engineering look like Civil Engineering: This is where the iterative and waterfall methodologies came from"​​.
Unified Process (UP)
Discussion: Unified Process (UP) integrates Agile methodologies, focusing on iterative and incremental development while adapting to changing requirements. It addresses the shortcomings of earlier methodologies by emphasizing user stories and continuous feedback.
Citation: "Unified Process is a wrapper around the processes of Agile Software development. UP touches on all the pain points which lead up to the Software Crisis"​​.

Short Answer Format Questions for Student Comprehension

Question: What were the main issues that led to the software crisis, and how did the traditional approach to software development contribute to these issues?
Answer: The main issues of the software crisis included cost overruns, schedule delays, and poor quality. Treating software development like civil engineering, with rigid, linear methodologies, failed to accommodate the iterative nature of software projects and the need for continuous feedback.
Question: How does the Unified Process (UP) address the shortcomings of earlier software development methodologies?
Answer: The Unified Process (UP) incorporates Agile principles, focusing on iterative and incremental development. It emphasizes continuous feedback, user stories, and adaptability to changing requirements, thus addressing the inflexibility and inefficiency of earlier methodologies.
Question: In what ways did treating software development like civil engineering lead to the software crisis?
Answer: Treating software development like civil engineering imposed rigid, sequential phases that did not accommodate the need for iterative progress and continuous integration. This led to poor adaptability, high costs, delays, and quality issues.
Question: What are some key practices of the Unified Process (UP) that help prevent the issues experienced during the software crisis?
Answer: Key practices of UP include iterative development, use of user stories, continuous feedback loops, and integration of Agile methodologies. These practices ensure that development is more flexible, adaptive, and aligned with user needs, preventing many issues of the software crisis.
These questions and answers will help students to assess their understanding of the software crisis and the benefits of the Unified Process in software engineering.



June 4:
Here are 3 representative questions from last week's material that could be used for this week's review topics quiz:
image.png
Explain the differences between model view controller architecture and how AI language models are incorporated into software systems.
What are the main components of an AI software architecture according to the lecture, and what is the purpose of each component?
Why is understanding the intended purpose or business problem an AI model aims to address considered important before beginning the model development process? A. Can this problem be solved?
B. What would a “good” solution look like?
C. Given that this is an AI application: Can we source Training Data of suitable diversity to train our model?


The main differences between model view controller architecture and how AI language models are incorporated are:
In MVC, the controller contains deterministic business rules/algorithms coded with if/then statements. In AI architecture, the AI language model replaces the controller and can output responses based on its training data, not just predefined rules.
MVC separates the database/model from the controller logic. In AI architecture, the training data and AI model together represent the business domain/rules, rather than being separated.
AI architecture still uses views for user interaction and databases for data storage, but the AI model acts as both the controller and encapsulates the business domain knowledge from its training data.


2024 June 7 Warm up topics:

1. **How did we suggest businesses can leverage AI-driven segmentation to improve customer interactions?** - Sigurdson emphasizes the importance of leveraging data analytics and AI-driven segmentation to personalize interactions with customers and provide valuable insights. Examples include companies like Starbucks and Walmart that use AI to gain unprecedented insights into individual customer preferences.
2. **What is the potential impact of expert-based systems in medicine, as discussed by Peter Sigurdson?** - Expert-based systems in medicine can curate and aggregate crowd-sourced knowledge from thousands of practitioners, helping more junior or less experienced medical practitioners make more informed decisions in real-time and amplify their knowledge. AI Expert Systems can assist more junior practitioners to more complex procedures.
3. **How did we describe the role of large language models in future IT business applications?** - Sigurdson predicts that AI large language models will replace deterministic outputs of objects and controllers in IT business applications, providing rich and nuanced responses trained on large datasets, surpassing current crowdsourced knowledge.
4. **What example did we study to illustrate the effectiveness of personalized marketing using AI?** - Sigurdson cites Starbucks' personalized marketing strategy, which leverages vast amounts of customer data to create individualized profiles and offers. This strategy demonstrates how AI can deliver personalized content and recommendations based on customer behavior.
5. **What are some tools and methodologies for AI model development in business operations?** - Sigurdson mentions using tools like Git for version control, JIRA for development lifecycle management, and technologies such as Apache Kafka and Spark for real-time data processing and analytics. He also highlights the use of Azure for AI development due to its ease of use and scalability.

June 7 Topics:



2024 May 28 Start of Class Warm up Questions
info

Concepts review questions focusing on technology, data handling, and product architecture in building AI models for business applications:

What is the role of Docker in AI model development, and how does it facilitate the development process?
Docker provides a consistent environment for AI model development by containerizing the software dependencies, libraries, and configurations. This ensures that the application runs the same way on any system, thus simplifying deployment and scalability.
Explain the concept of Continuous Integration (CI) and Continuous Deployment (CD) and how they improve collaboration and code quality in AI projects.
CI/CD practices involve automating the process of integrating code changes and deploying them to production environments. CI focuses on frequent code integrations and automated testing, while CD automates the deployment of code changes. This leads to more reliable and faster delivery of software, improved collaboration, and higher code quality.
Describe the importance of data handling in the context of building AI models and provide an example of a data storage solution used in AI projects.
Effective data handling is crucial for the accuracy and efficiency of AI models. It involves managing large datasets, ensuring data quality, and optimizing data retrieval. An example is using NoSQL databases like MongoDB, which are well-suited for handling unstructured data and scaling horizontally.
What are embeddings in the context of natural language processing (NLP), and why are they important in building AI models?
Embeddings are vector representations of words or phrases that capture their meanings, syntactic properties, and semantic relationships. They are important because they enable AI models to understand and process language by converting text into numerical form that can be used in machine learning algorithms.
Outline the typical stages of a continuous delivery pipeline and the key activities involved in each stage.
A typical continuous delivery pipeline includes the following stages:
Build: Pulling code from version control, compiling, and packaging.
Test: Running automated tests to verify the build's quality.
Deploy: Deploying the build to various environments (development, testing, production).
Monitor: Monitoring the deployed application to ensure it runs smoothly and meets performance standards.

These questions cover key aspects of technology and data handling in AI model development, ensuring students grasp fundamental concepts required for building robust AI solutions.

2024 May 24:

Start-of-class warm-up quiz questions, along with detailed answers, code examples, and commercial business illustrations for each concept:

1. What is the primary purpose of an AI language model?
The primary purpose of an AI language model is to generate human-like text based on the input it receives. (prompt). These models are used for a variety of applications, including text completion, translation, summarization, and conversation simulation.
A complete standalone example that can be run in a Google Colab notebook. This includes installing the required libraries, loading a pre-trained GPT-2 model, encoding input text, generating output, and printing the generated text.
Full Collab Notebook Code
# Install the transformers library !pip install transformers
# Import necessary libraries from transformers import GPT2LMHeadModel, GPT2Tokenizer
# Load pre-trained model and tokenizer model_name = 'gpt2' model = GPT2LMHeadModel.from_pretrained(model_name) tokenizer = GPT2Tokenizer.from_pretrained(model_name)
# Encode input text input_text = "How were early CPUs constructed?" input_ids = tokenizer.encode(input_text, return_tensors='pt')
# Generate text output = model.generate(input_ids, max_length=50, num_return_sequences=1) generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
# Print the generated text print(generated_text) ```
### Step-by-Step Explanation:
1. **Install Transformers Library:** The first step is to install the `transformers` library from Hugging Face. This library provides pre-trained models and tokenizers.
```python !pip install transformers ```
2. **Import Necessary Libraries:** Import the `GPT2LMHeadModel` and `GPT2Tokenizer` from the `transformers` library.
```python from transformers import GPT2LMHeadModel, GPT2Tokenizer ```
3. **Load Pre-Trained Model and Tokenizer:** Load the pre-trained GPT-2 model and tokenizer using their names.
```python model_name = 'gpt2' model = GPT2LMHeadModel.from_pretrained(model_name) tokenizer = GPT2Tokenizer.from_pretrained(model_name) ```
4. **Encode Input Text:** Encode the input text into tokens that the model can understand.
```python input_text = "What is the purpose of AI language models?" input_ids = tokenizer.encode(input_text, return_tensors='pt') ```
5. **Generate Text:** Generate text using the model. Specify the maximum length of the generated text and the number of sequences to return.
```python output = model.generate(input_ids, max_length=50, num_return_sequences=1) ```
6. **Decode and Print the Generated Text:** Decode the generated tokens back into human-readable text and print it.
```python generated_text = tokenizer.decode(output[0], skip_special_tokens=True) print(generated_text) ```
Copy and paste this entire code block into a Google Colab notebook, and run it. This will install the necessary libraries, load the model, encode your input text, generate a response, and display the generated text. ```

Commercial Business Illustration:

AI language models are used by customer service chatbots to handle inquiries and provide instant responses to customer questions. For example, companies like Zendesk and Intercom integrate AI language models into their customer support systems to improve efficiency and customer satisfaction.


2. Explain the concept of a 'transformer' in the context of AI.

A transformer is a deep learning model architecture that uses self-attention mechanisms to process input data.
It enables models to understand the context of each word in a sentence by looking at the relationships between all words in the input text simultaneously.
Here is the complete code that you can run in a Google Colab notebook. This will install the required libraries, load a pre-trained BERT model, encode input text, perform a forward pass, and print the last hidden states.
### Full Colab Notebook Code
```python # Install the transformers library !pip install transformers
# Import necessary libraries from transformers import BertModel, BertTokenizer
# Load pre-trained model and tokenizer model_name = 'bert-base-uncased' model = BertModel.from_pretrained(model_name) tokenizer = BertTokenizer.from_pretrained(model_name)
# Encode input text input_text = "Explain the concept of a transformer in AI." inputs = tokenizer(input_text, return_tensors='pt')
# Forward pass outputs = model(**inputs) last_hidden_states = outputs.last_hidden_state
# Print the last hidden states print(last_hidden_states) ```
### Step-by-Step Explanation:
1. **Install Transformers Library:** Install the `transformers` library from Hugging Face, which provides pre-trained models and tokenizers.
```python !pip install transformers ```
2. **Import Necessary Libraries:** Import the `BertModel` and `BertTokenizer` from the `transformers` library.
```python from transformers import BertModel, BertTokenizer ```
3. **Load Pre-Trained Model and Tokenizer:** Load the pre-trained BERT model and tokenizer using their names.
```python model_name = 'bert-base-uncased' model = BertModel.from_pretrained(model_name) tokenizer = BertTokenizer.from_pretrained(model_name) ```
4. **Encode Input Text:** Encode the input text into tokens that the model can understand. The tokenizer converts the input text into token IDs and returns a tensor.
```python input_text = "Explain the concept of a transformer in AI." inputs = tokenizer(input_text, return_tensors='pt') ```
5. **Forward Pass:** Perform a forward pass through the model to get the outputs, which include the last hidden states.
```python outputs = model(**inputs) last_hidden_states = outputs.last_hidden_state ```
6. **Print the Last Hidden States:** Print the last hidden states, which contain the contextualized representations of each token in the input text.
```python print(last_hidden_states) ```
Copy and paste this entire code block into a Google Colab notebook, and run it. This will install the necessary libraries, load the model, encode your input text, perform a forward pass, and display the last hidden states.
- **Commercial Business Illustration:** Transformers are used in natural language processing tasks like translation and text generation. Google Translate uses transformer models to provide accurate and context-aware translations across multiple languages.

3. **What are the differences between a database and an AI language model?

- **Answer:** A database stores structured data and retrieves specific information based on queries. An AI language model, on the other hand, generates text or responses based on learned patterns from large datasets. Databases require precise queries, while AI language models can handle open-ended questions and generate human-like text.
- **Code Example:** ```sql -- SQL query to retrieve specific information from a database SELECT product_name, price FROM products WHERE category = 'Electronics'; ```
```python from transformers import GPT2LMHeadModel, GPT2Tokenizer
# AI language model generating a response input_text = "Tell me about the latest advancements in AI." input_ids = tokenizer.encode(input_text, return_tensors='pt') output = model.generate(input_ids, max_length=100, num_return_sequences=1) generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
print(generated_text) ```
- **Commercial Business Illustration:** Traditional databases are used in e-commerce websites to store and retrieve product information. AI language models are used in virtual assistants like Amazon's Alexa and Apple's Siri to handle a wide range of user queries and provide conversational responses.

4. **Define 'conversational memory' and explain its importance in AI chatbots.** - **Answer:** Conversational memory refers to the ability of an AI chatbot to remember previous interactions with a user. This memory helps the chatbot maintain context and provide more relevant and coherent responses in ongoing conversations.
This example initializes a simple conversational memory and demonstrates how to interact with the model in a conversational manner.
### Full Colab Notebook Code
```python # Install the transformers library !pip install transformers
# Import necessary libraries from transformers import GPT2LMHeadModel, GPT2Tokenizer
# Load pre-trained model and tokenizer model_name = 'gpt2' model = GPT2LMHeadModel.from_pretrained(model_name) tokenizer = GPT2Tokenizer.from_pretrained(model_name)
# Initializing a simple conversational memory conversation_history = []
def chat_with_model(input_text): conversation_history.append(input_text) input_ids = tokenizer.encode(" ".join(conversation_history), return_tensors='pt') output = model.generate(input_ids, max_length=100, num_return_sequences=1, pad_token_id=tokenizer.eos_token_id) response = tokenizer.decode(output[0], skip_special_tokens=True) conversation_history.append(response) return response
# Example conversation print(chat_with_model("Hi, how can you assist me today?")) print(chat_with_model("Tell me about your services.")) ```
### Step-by-Step Explanation:
1. **Install Transformers Library:** Install the `transformers` library from Hugging Face, which provides pre-trained models and tokenizers.
```python !pip install transformers ```
2. **Import Necessary Libraries:** Import the `GPT2LMHeadModel` and `GPT2Tokenizer` from the `transformers` library.
```python from transformers import GPT2LMHeadModel, GPT2Tokenizer ```
3. **Load Pre-Trained Model and Tokenizer:** Load the pre-trained GPT-2 model and tokenizer using their names.
```python model_name = 'gpt2' model = GPT2LMHeadModel.from_pretrained(model_name) tokenizer = GPT2Tokenizer.from_pretrained(model_name) ```
4. **Initialize Conversational Memory:** Initialize an empty list to store the conversation history.
```python conversation_history = [] ```
5. **Define the Chat Function:** Define a function to interact with the model. This function will: - Add the input text to the conversation history. - Encode the entire conversation history into tokens. - Generate a response using the model. - Decode the response and add it to the conversation history. - Return the response.
```python def chat_with_model(input_text): conversation_history.append(input_text) input_ids = tokenizer.encode(" ".join(conversation_history), return_tensors='pt') output = model.generate(input_ids, max_length=100, num_return_sequences=1, pad_token_id=tokenizer.eos_token_id) response = tokenizer.decode(output[0], skip_special_tokens=True) conversation_history.append(response) return response ```
6. **Example Conversation:** Demonstrate an example conversation by calling the `chat_with_model` function with different inputs.
```python print(chat_with_model("Hi, how can you assist me today?")) print(chat_with_model("Tell me about your services.")) ```
Copy and paste this entire code block into a Google Colab notebook, and run it. This will install the necessary libraries, load the model, encode your input text, generate responses, and maintain a simple conversational memory.
- **Commercial Business Illustration:** AI chatbots used by customer support services, such as those provided by Drift or LivePerson, leverage conversational memory to provide consistent and personalized assistance, improving the overall user experience.



5. What is meant by 'Bayesian training methods' in the context of AI model training?

- **Answer:** Bayesian training methods involve using Bayes' theorem to update the probability of a hypothesis as more evidence or data becomes available. In AI, this method helps in refining the model's predictions by continuously incorporating new data and adjusting the probabilities.
megaphone
This includes all the necessary setup and installation steps.
### Full Colab Notebook Code
```python # Install necessary libraries !pip install -U scikit-learn
# Import necessary libraries from sklearn.linear_model import BayesianRidge import numpy as np
# Example data X = np.array([[1, 1], [2, 2], [3, 3], [4, 4]]) y = np.dot(X, np.array([1, 2])) + 3
# Bayesian Ridge Regression model = BayesianRidge() model.fit(X, y) predictions = model.predict(X)
# Print the predictions print("Predictions:", predictions) ```
### Step-by-Step Explanation:
1. **Install Necessary Libraries:** Ensure that `scikit-learn` is installed. In a Google Colab notebook, you can install it using the following command:
```python !pip install -U scikit-learn ```
2. **Import Necessary Libraries:** Import the `BayesianRidge` class from `sklearn.linear_model` and `numpy` for numerical operations.
```python from sklearn.linear_model import BayesianRidge import numpy as np ```
3. **Example Data:** Create example data for the regression task. In this case, we generate a simple dataset with features `X` and target values `y`.
```python X = np.array([[1, 1], [2, 2], [3, 3], [4, 4]]) y = np.dot(X, np.array([1, 2])) + 3 ```
4. **Bayesian Ridge Regression:** Initialize the `BayesianRidge` model, fit it to the data, and make predictions.
```python model = BayesianRidge() model.fit(X, y) predictions = model.predict(X) ```
5. **Print the Predictions:** Print the predictions to verify the output of the model.
```python print("Predictions:", predictions) ```
Copy and paste this entire code block into a Google Colab notebook, and run it. This will install the necessary libraries, create example data, fit a Bayesian Ridge regression model to the data, make predictions, and print the predictions.
- **Commercial Business Illustration:** Bayesian methods are used in recommendation systems, such as those employed by Netflix and Amazon. These systems continuously update their recommendations based on user interactions, improving the accuracy and relevance of suggested content.

6. **Describe the concept of 'model federation' and its potential benefits.** - **Answer:** Model federation refers to the practice of training multiple AI models across different data sources and then combining their knowledge to create a more robust and comprehensive model. This approach allows for the integration of diverse datasets while maintaining data privacy and security.
- **Code Example:** ```python from transformers import pipeline
# Simulating model federation with multiple models model1 = pipeline('text-generation', model='gpt2') model2 = pipeline('text-generation', model='distilgpt2')
input_text = "Describe the potential benefits of model federation." response1 = model1(input_text, max_length=50) response2 = model2(input_text, max_length=50)
print("Model 1 Response:", response1[0]['generated_text']) print("Model 2 Response:", response2[0]['generated_text']) ```
- **Commercial Business Illustration:** Model federation is used in healthcare to combine insights from different medical institutions without sharing sensitive patient data. Federated learning platforms like Google's TensorFlow Federated allow multiple entities to collaboratively train models while preserving data privacy.
These detailed explanations, code examples, and business illustrations should help your students grasp the key concepts discussed in your class.


What tools and platforms are available to use to develop Python AI Applications?
Local premises / Your own computer. Might be resource-constrained. Not enough RAM and CPU for serious AI adventures.
Google Collab Notebook:
Free
Cloud-based : Share URLs to share editting with the team. Very powerful. Pro version available for a small price.
HuggingFace Spaces : Cloud based. Free with an inexpensive cloud-based version.
Provides a library of many language models that you can integrate into your own projects.
You can also use the hugging face hosted language models in Google collab notebook. by installing and we're gonna see that activity in our lab in a little while. you can install you can import the hugging face package in Python, and then you can get access to all of the goodies on hugging face in your Python code either. in local premises or in Google collab.
Runpod.io


What project deliverables will you present?


megaphone

What concept in machine learning uses Transfer Learning from a TEACHER MODEL like Baby Lllama or Chat GPT 3.5 to “get” the tokens and weightings from a high information density model:

Key points of transfer learning:
When we want to make an AI language model: 2 options:
We can train it “from scratch”. Using a large training corpus. And using large amounts of GPU Cores. Very expensive, time consuming, takes a lot of skilled AI cognitive systems trainers, particularly to do the Human Loop Feedback Training.
Option B: Transfer Learning: Less expensive and more accessible to everyday on the job AI application Developers is “transfer learning”. We start with an established model, and “borrow” or use the Teacher Model’s tokens and weighting: Commonly used models are Baby Llama, Vicuna, Chat GPT 3.5.
We will see how we can use Hugging Face Spaces to build programs with do API calls with PYTORCH and Tensor Flow to do this training.
Considerations on what Teacher Model you use may include: Licensing terms for commercial use.

Understanding Dynamic and Static Computation Graphs

Teaching Point:
PyTorch uses dynamic computation graphs (eager execution), which are constructed on-the-fly during each forward pass,
while TensorFlow 1.x uses static computation graphs, which are defined before running. TensorFlow 2.x, however, supports eager execution by default.

Question: In which framework are computation graphs constructed on-the-fly during each forward pass, providing more flexibility and ease of debugging?
Answer: PyTorch uses dynamic computation graphs (eager execution), which are constructed on-the-fly during each forward pass, providing more flexibility and ease of debugging.


Below are the questions designed to act as mini-lectures
Build Process:
PFEQ:

What do Operating Systems do:

1. Provides a Hypervisor, which is a Software layer that provides APIs to enable Application Software (Chrome, MS Word) to run and provide their services.

2 Provides the ability to create user accounts / password.

3. SAM Security access manager: Provisions a way to enable / deny user accounts from accessing system resources.

Thought Question: What is the difference between a Type 1 Bare Metal Hypervisor and an Operating System.

Type 1 Hypervisor: Bare Metal
Type 2: Lives as a guest with a HOST operating system.
What is the difference between a
Virtual Machines

Docker

Ansible


Learning Outcomes:
Build insight into the role of JSON schema in AI model engineering, particularly in handling big data and aiding AI models in learning from user interactions.
The correct answer for each question is marked with an asterisk (*).
Question 1:
What is the primary role of utilizing JSON schema in handling big data for AI applications?
a) Only for storing user data
b) Only for AI model evaluation
*c) Organizing and validating the structure of large datasets for efficient processing and training of AI models: being text, json data stores are easily input/output with PYTHON: One big win with JSON database schema: you can change the shape of the data container at runtime with program code.
d) Only for visual representation
Explanation:
JSON schema is primarily used to organize and validate the structure of large datasets in AI applications.
It ensures the data is in the correct format for efficient processing and training of AI models, contributing to the effective learning and functioning of AI systems, and allowing us to run CI / CD model training processes.

Question 2:
How does JSON schema assist in improving the conversational memory of an AI model?
a) By increasing the model's size
*b) By ensuring structured and consistent data storage and retrieval for learning from user interactions
c) By reducing the model's complexity
d) By focusing only on the graphical interface
Explanation:
JSON schema aids in enhancing the conversational memory of an AI model by ensuring structured and consistent data storage and retrieval. This consistency enables the AI model to effectively learn from user interactions, further refining its responses and interactions.
Question 3:
In the context of AI applications, how does JSON schema contribute to model engineering?
a) By only dealing with front-end interactions
b) By only handling model deployment
*c) By providing a standardized structure for data, facilitating efficient model training and development
d) By focusing only on cost reduction
Explanation:
JSON schema offers a standardized data structure, crucial for efficient model training and development in AI applications. A standardized and organized data format aids in seamless and effective model engineering, contributing to the building of robust AI systems.
Question 4:
Why is the consistent structure provided by JSON schema essential for AI models to learn from user interactions?
a) Only for improving visual elements
*b) It ensures reliable and orderly data storage, aiding in effective learning and memory retention for AI models
c) Only for enhancing security
d) Only for reducing computation time
Explanation:
A consistent data structure assured by JSON schema is pivotal as it guarantees reliable and orderly data storage. This organization is crucial for AI models to effectively learn and retain information from user interactions, enhancing their performance and response generation.
Question 5:
How does the use of JSON schema in AI model engineering align with big data processing?
a) Only for data deletion
*b) It aids in handling and processing large datasets efficiently, ensuring AI models have ample and structured data for training and learning
c) Only for data encryption
d) Only for improving data visualization
Explanation:
Utilizing JSON schema in AI model engineering is harmonious with big data processing as it assists in efficiently handling and processing large datasets. This efficiency ensures that AI models have access to ample and well-organized data for robust training and learning, enhancing their performance and capabilities.

Below are the questions concentrating on the integration of virtual machines and Ansible in the AI model build process.
Question 1:
How does utilizing virtual machines in AI model building enhance the development process?
a) Only for data visualization
*b) By providing isolated and replicable environments for consistent model development and testing
c) Only for improving data security
d) By reducing the need for data preprocessing
Explanation:
Virtual machines furnish isolated and replicable environments, enhancing the consistency and reliability of AI model development and testing. This ensures uniformity in development environments, contributing to efficient and reliable model building.
Question 2:
What is the role of Ansible in automating the AI model building process?
a) Only for handling data encryption
*b) It automates the configuration and deployment processes, ensuring consistent and efficient setup of development environments
c) Only for front-end development
d) It handles only the data visualization
Explanation:
Ansible plays a critical role in automating the configuration and deployment processes in AI model building. It ensures a consistent and efficient setup of development environments, minimizing manual errors and enhancing development speed and reliability.
Question 3:
How do virtual machines contribute to scalable AI model development?
a) Only by reducing computation time
*b) By allowing scalable and flexible resource allocation for model development and testing
c) Only by improving user interface
d) Only by handling data cleaning
Explanation:
Virtual machines contribute to the scalability of AI model development by allowing scalable and flexible resource allocation. This adaptability ensures that AI models can be developed and tested with varying resource allocations, enhancing the efficiency and flexibility of the model building process.
Question 4:
Why is Ansible's automation crucial for effective AI model building on virtual machines?
a) Only for enhancing graphical representation
*b) It ensures consistent and error-free configuration and deployment on virtual environments, enhancing the efficiency and reliability of AI model building
c) Only for data deletion
d) Only for data storage
Explanation:
Ansible’s automation is pivotal for AI model building on virtual machines as it ensures consistent and error-free configuration and deployment on virtual environments. This automation enhances the efficiency and reliability of AI model building by minimizing manual intervention and errors.
Question 5:
How does the combination of virtual machines and Ansible facilitate effective AI model development?
a) Only for improving security
*b) By ensuring scalable, consistent, and automated setup and deployment for AI model building
c) Only for data visualization
d) Only for reducing model size
Explanation:
The amalgamation of virtual machines and Ansible facilitates effective AI model development by ensuring scalable, consistent, and automated setup and deployment. This combination guarantees a streamlined and reliable model building process, aiding in the development of robust AI models.
Question 6:
What is a significant benefit of using virtual machines and Ansible in tandem for AI model building?
a) Only for enhancing model evaluation
*b) Enhanced scalability, automation, and consistency in the AI model building process
c) Only for improving data encryption
d) Only for front-end development
Explanation:
Employing virtual machines and Ansible in tandem for AI model building offers enhanced scalability, automation, and consistency in the AI model building process. This dual integration optimizes the overall development process, contributing to the building of robust and efficient AI models.

Feb 6
If you could build your own CI CD Pipeline: What would it look like #PFEQ

Jan 30

megaphone

Question:

Thomas Codd speaks to the class: "As the inventor of the relational database model, I pioneered the use of SQL for structured data querying. However, in the realm of probabilistic computing and tensor operations in TensorFlow and PyTorch Python Libraries, my invention of SQL faces limitations.

The PYTORCH Tensor File IS the AI Model ! The PYTORCH tensor file is a numeric format data file which contains the WORD EMBEDDING and some support code structures to enable your AI MODEL (which IS the Pytorch Tensor File) to be queried from “outside” and to return answers.
image.png
Standard Website: MVC Model View Controller
The pattern of how we build an AI Application:
Model = The Database
View : HTTP Server / AI Application Server uses microservices architecture to receive requests (prompts) : sends back the answer.
Controller:
Web application: Node.js program OO
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.