Introduction To ChatGPT For Engineers
Introduction To ChatGPT For Engineers
Introduction to ChatGPT
2023
Course Description
In this course, you will gain a comprehensive understanding of ChatGPT and its
applications in natural language processing (NLP). You will learn about the basics of
NLP and transformer architecture, which is the basis for GPT. Additionally, you will
explore the limitations and ethical considerations associated with using GPT. By the
end of this course, you will have a good understanding of NLP and GPT, and be able
to apply this knowledge to your professional endeavors.
This course includes a multiple-choice quiz at the end, which is designed to enhance
your understanding of the course materials.
Learning Objectives
©2023 Page 2 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
Table of Contents
©2023 Page 3 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
Introduction to ChatGPT
Helen Chen, Ph.D., PE, LEED AP
Introduction
ChatGPT (short for "chat-based Generative
Pre-training Transformer") was launched as
a prototype on November 30, 2022, and
quickly garnered attention for its detailed
responses and articulate answers across
many domains of knowledge. This course
presents an overview of this powerful tool to
engineers and land surveyors, provides
guidance on how to use ChatGPT effectively,
and discusses the advantages and limitations of the generative pre-trained
transformer (GPT). As you work through the course materials, it is highly
recommended to visit the OpenAI website (https://chat.openai.com/chat) and
interact with ChatGPT to gain a firsthand understanding of its capabilities.
AI-Related Terminology
Understanding these terms will enhance your understanding of the course material:
Artificial Intelligence (AI) - The branch of computer science that deals with
creating machines that can perform tasks that would normally require human
intelligence.
Deep Learning (DL) - A subset of ML that uses deep neural networks to improve
the performance of AI systems.
©2023 Page 4 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
F1-Score - A measure of a model's accuracy that takes into account both precision
and recall. It is calculated as the harmonic mean of precision and recall, where the
best value is 1.0 and the worst value is 0.0.
Generative Models - A type of model that can generate new data, such as text or
images, based on training data.
Machine Learning (ML) - A type of AI that allows systems to learn and improve
from experience without being explicitly programmed.
Transformer - A deep learning model introduced in the paper "Attention Is All You
Need" by Google researchers in 2017. It is designed for natural language
processing tasks, such as language translation and text summarization.
©2023 Page 5 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
Training
OpenAI developed the ChatGPT model using a method known as Reinforcement
Learning from Human Feedback (RLHF), which is similar to the method used for
InstructGPT. However, there were slight variations in the data collection process.
Initially, OpenAI fine-tuned the model using supervised learning, where human
trainers engaged in conversations, assuming the roles of both the user and AI
assistant. The trainers were provided with suggestions generated by the model to
aid in composing their responses. The new dialogue dataset was then combined
with the InstructGPT dataset, which had been transformed into a dialogue format.
ChatGPT is fine-tuned from a model in the GPT-3.5 series, which finished training in
early 2022. ChatGPT and GPT 3.5 were trained on an Azure AI supercomputing
infrastructure.
Source: https://openai.com/blog/chatgpt/
©2023 Page 6 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
What is ChatGPT?
ChatGPT is a large language model developed by OpenAI that uses deep learning
techniques to generate text with a more natural flow, giving you the feeling of
conversing with a real person. When you type in a query, you should receive a
response that includes several sentences or paragraphs.
©2023 Page 7 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
What Is a Prompt?
A prompt is a phrase or individual keywords used as input to an AI tool like
ChatGPT. The tool then tries to analyze and understand the input and automatically
generates a response. So it’s important that you word your prompts in a way that
the tool can understand.
When writing prompts for ChatGPT there are some points to consider. First, the
prompt should be worded to include a clear task or question. Even though AI is
capable of processing incomplete or incorrect input, it is still helpful to give the tool
clear instructions.
Another important point is the choice of the right keywords. These should be as
precise and accurate to the question or task as possible. Only then can the AI tool
interpret the input correctly and deliver the desired results.
When you start working with ChatGPT, it is important that you write your prompts
correctly. A good prompt can help the tool work better and help you achieve your
goals. For this reason, we want to give you some examples of good and bad
prompts to give you a better idea of what to avoid.
Good prompts:
• "Generate a conversation between two friends discussing their plans for the
weekend."
• "Write a descriptive passage about a sunset on the beach."
• "Generate a script for a news segment about the latest breakthrough in
renewable energy."
• "Write a letter to a friend about the impact of the COVID-19 pandemic on
your life."
• "Write a short story about a robot who gains consciousness."
Bad prompts:
©2023 Page 8 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
The model is pre-trained on a large dataset of text, which allows it to learn the
statistical patterns and relationships between words and phrases in the language.
During the training process, the model is exposed to a large number of examples of
text, which allows it to learn how to generate and understand human language.
When given a prompt, the model uses this pre-trained knowledge to generate text
that is similar to the examples it was trained on.
The pre-training approach and the transformer architecture of GPT allow the model
to generate high-quality text, perform well on a wide range of language tasks with
minimal task-specific fine-tuning, and it's also able to generate human-like text.
However, it also requires large amounts of computational resources and may
generate biased or incorrect responses if the pre-training data contains biases.
©2023 Page 9 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
energy building?" You can also get more specific and request a specific number of
paragraphs for an essay or a Wikipedia page.
©2023 Page 10 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
ChatGPT is not foolproof, though; if there is not enough data available, it may fill in
the gaps with incorrect information. OpenAI notes this is rare and that the tool also
currently has “limited knowledge of world events after 2021”, since it was trained
on data before the date.
OpenAI has released an official API for ChatGPT, which allows developers to easily
integrate the model into their applications and use it for a wide range of natural
language processing tasks, such as language translation, text summarization, and
question answering. The API provides access to the latest version of the model, and
enables fine-tuning on specific tasks and data sets. Additionally, the API allows for
easy integration with other services and platforms, such as cloud-based APIs and
web applications.
©2023 Page 11 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
• Setting the context: The prompt sets the context for the conversation, giving
the model an understanding of the topic and any relevant background
information.
• Defining the scope: The prompt defines the scope of the conversation,
allowing the model to focus on specific aspects of the topic and provide
relevant information.
• Guiding the conversation: The prompt guides the conversation by providing a
starting point for the model's response, which can influence the direction of
the conversation.
©2023 Page 12 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
Crafting clear and concise prompts when using a language model like ChatGPT can
lead to a number of benefits:
• Increased accuracy: Clear and specific prompts make it easier for the model
to understand the intent behind the question and provide a more accurate
answer.
• Reduced response time: Concise prompts allow the model to quickly
understand the question and generate a response, reducing the overall time
it takes to get an answer.
• More efficient use of resources: When prompts are clear and specific, the
model is able to provide an answer with less computation, which can be more
efficient in terms of processing power and memory usage.
• Better understanding of context: Clear and specific prompts help the model
understand the context of the question, which can lead to more relevant and
useful answers.
• Better user experience: When prompts are clear and concise, it is easier for
the user to understand the question and the model's answer, which can lead
to a more positive and productive conversation.
In summary, crafting clear and concise prompts in ChatGPT conversation can help
to improve the overall accuracy and efficiency of the model, as well as the user's
experience.
1. Offer context
Just like humans, AI does better with context. Think about exactly what you want
the AI to generate, and provide a prompt that's tailored specifically to that.
Let's say you want ChatGPT to write a speaker's introduction for yourself: how is
the AI supposed to know about you? It's not that smart (yet). But you can give it
the information it needs, so it can reference it directly. For example, you could copy
©2023 Page 13 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
your resume or LinkedIn profile and paste it at the top of your prompt. Likewise, if
you want the AI to summarize an article for you, you need to paste the full text of
the article above your prompt “Summarize the content from the above article with
5 bullet points.”
3. Give examples
Providing examples in the prompt can help the AI understand the type of response
you're looking for.
It's helpful to provide a word count for the response, so you don't get a 400-word
answer when you were looking for a sentence (or vice versa). You might even use a
range of acceptable lengths.
For example, if you want a 300-word response, you could provide a prompt like
"Write a 300-450-word summary of this article." This gives the AI the flexibility to
generate a response that's within the specified range. You can also use less precise
terms like "short" or "long."
Sometimes it's just about finding the exact phrase that OpenAI will respond to.
Here are a few phrases that others have found work well with OpenAI to achieve
certain outcomes.
This makes the AI think logically and can be specifically helpful with math
problems.
"Thinking backwards"
This helps frame the bot's knowledge, so it knows what it knows—and what it
doesn't.
©2023 Page 14 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
• Language Translation: A system that can translate text from one language to
another, for example, translating a news article from Spanish to English.
• Text Summarization: A system that can automatically generate a summary
of a long article or document, for example, summarizing a research paper
into a few key points.
• Sentiment Analysis: A system that can determine the sentiment or emotional
tone of a piece of text, for example, determining whether a customer review
of a product is positive or negative.
• Named Entity Recognition (NER): A system that can identify and extract
specific information such as people, places, and organizations from a text, for
example, identifying that "Barack Obama" is a person and "United States" is
a location in a news article.
• Part-of-Speech Tagging: A system that can identify and label the
grammatical parts of speech in a sentence, such as nouns, verbs, and
adjectives, for example, tagging "The cat sat on the mat" into "The/Det
cat/Noun sat/Verb on/prep the/Det mat/Noun"
• Parsing: A system that can analyze the syntactic structure of a sentence, for
example, understanding that "The cat sat on the mat" is a sentence with the
subject "cat" and object "mat"
• Question Answering (QA): A system that can understand the intent behind a
question and provide a relevant answer, for example, answering the question
"What is the capital of France?" with "Paris"
• Text Generation: A system that can create new text based on a given input,
for example, generating a continuation of a given sentence or generating a
new sentence based on a set of keywords.
These are just a few examples of the many tasks and applications that NLP systems
can be used for. It's important to note that NLP systems can be rule-based,
statistical, or neural network-based and the performance and accuracy may vary
depending on the task and the model used.
©2023 Page 15 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
Additionally, NLP is also being used in healthcare, e-commerce, and many other
industries. In healthcare, NLP-powered systems can extract useful information from
medical records and assist in diagnosis. In e-commerce, NLP-powered systems can
be used to extract information from product reviews and provide a summary.
In traditional NLP models, the model is trained for a specific task using a labeled
dataset. For example, a sentiment analysis model is trained using a labeled dataset
of text samples with their corresponding sentiment labels (e.g. positive, negative).
GPT is different in the sense that it is pre-trained on a large corpus of text data
without any specific task in mind. This pre-training allows the model to learn
general language patterns and representations, which can then be fine-tuned for
specific tasks with a smaller labeled dataset.
The transformer architecture has two main components: the encoder and the
decoder. The encoder is responsible for encoding the input sequence into a fixed-
length representation, and the decoder is responsible for generating the output
sequence.
The pre-training approach and the transformer architecture of GPT allow the model
to generate high-quality text, perform well on a wide range of language tasks with
minimal task-specific fine-tuning, and it's also able to generate human-like text.
However, it also requires large amounts of computational resources and may
generate biased or incorrect responses if the pre-training data contains biases.
GPT can be used in a variety of ways depending on the specific task and
requirements. Here are a few examples of the different ways that GPT can be used:
• Fine-tuning GPT on a specific task: One of the most common ways to use
GPT is to fine-tune it on a specific task, such as language translation, text
©2023 Page 17 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
It's worth noting that the specific use-case, resources, and requirements should be
considered when choosing which way to use GPT, and it's also important to
evaluate the performance and limitations of the model on the target task.
©2023 Page 18 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
There are several popular NLP libraries that provide pre-trained models and utilities
to fine-tune GPT on specific tasks. Here are a few examples of how to fine-tune GPT
on specific tasks using popular NLP libraries such as Hugging Face's Transformers
and TensorFlow:
©2023 Page 19 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
import tensorflow as tf
from transformers import GPT2Tokenizer, GPT2ForSequenceClassification
©2023 Page 20 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
Advantages of GPT
GPT has several advantages that make it a powerful and versatile language model.
Here are a few key advantages of GPT:
• Generating high-quality text: One of the main advantages of GPT is its ability
to generate high-quality and human-like text. This is due to its pre-training
on a large corpus of text data, which allows the model to learn general
language patterns and representations. This ability can be used for text
generation tasks such as story generation, poetry generation, and automated
content creation.
• Wide range of language tasks: GPT is trained on a wide range of text data,
which makes it capable of performing well on a wide range of language tasks.
It can be fine-tuned on specific tasks such as language translation, text
summarization, and question answering with minimal task-specific fine-
tuning. This is because the pre-training allows the model to learn general
language representations that can be useful for many tasks.
• Minimal task-specific fine-tuning: GPT is pre-trained on a large corpus of text
data, which means that it can be fine-tuned on specific tasks with a smaller
labeled dataset. This can save time and resources compared to traditional
models that require a large labeled dataset for each specific task.
• Smaller models: GPT models, especially GPT-3, have been trained on a large
amount of data and have billions of parameters, this allows them to have the
capability to perform well on a wide range of tasks with high quality and
accuracy.
• Flexible: GPT can be fine-tuned for a wide range of tasks, it also can be used
for different types of inputs such as text, speech, and video, and it can be
integrated into a wide range of applications such as chatbots, virtual
assistants, and automated content creation.
It's worth noting that GPT models can be quite large and computationally expensive
to fine-tune or use, so it's important to consider the specific use-case and available
resources when using GPT models.
©2023 Page 21 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
• Evaluating the model's performance on the target task: Before deploying GPT
in production, it is important to evaluate the model's performance on the
target task to ensure that it meets the desired accuracy and quality
requirements. This can be done by fine-tuning the model on a dataset
specific to the target task and evaluating the model's performance using
metrics such as precision, recall, and F1-score.
• Managing resources: GPT models require a significant amount of
computational resources to run, it is important to manage the resources
properly, for example using cloud-based infrastructure to manage the
resources.
• Handling bias and errors: GPT models can produce biased or incorrect
responses if the data used to fine-tune the model is biased or if the model is
not fine-tuned on a diverse dataset. To mitigate this, it is important to use a
diverse and unbiased dataset to fine-tune the model, and to evaluate the
model's performance on a diverse set of inputs.
• Monitoring the model's performance: Once GPT is deployed in production, it
is important to monitor the model's performance to detect any issues or
errors that may occur. This can be done by logging the model's inputs and
outputs, and by monitoring the model's performance metrics.
• Improving the model's performance over time: Once GPT is deployed in
production, it is important to continuously improve the model's performance
by fine-tuning it on new data, and by incorporating feedback from users.
By following these best practices, you can ensure that GPT is used effectively and
efficiently in production, and that it meets the desired quality and accuracy
requirements.
©2023 Page 22 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
• The current GPT model (GPT-3) has a limitation of not having access to
information on recent world events that occurred after 2021. This is because
the model was trained on a dataset that was last updated in 2021, so it does
not have knowledge of events that occurred after that date.
• ChatGPT sometimes writes plausible-sounding but incorrect or nonsensical
answers. According to OpenAI, fixing this issue is challenging, as: (1) during
RL training, there’s currently no source of truth; (2) training the model to be
more cautious causes it to decline questions that it can answer correctly; and
(3) supervised training misleads the model because the ideal answer
depends on what the model knows, rather than what the human
demonstrator knows.
©2023 Page 23 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
• Bias: GPT models are trained on large amounts of text data, which may
contain biases that are reflected in the model's outputs. This can result in
GPT producing biased or discriminatory responses, particularly when the data
used to fine-tune the model is not diverse and inclusive.
• Misinformation: GPT can generate high-quality text, but it can also generate
text that is factually incorrect or misleading. This is especially problematic
when GPT is used to generate news articles, product descriptions, or other
types of content that are meant to inform the public.
• Privacy: GPT models require large amounts of data to train, which may
include sensitive personal information. This raises privacy concerns and it is
important to ensure that the data used to train GPT models is properly
anonymized and that the models are not used to make decisions that impact
people's lives.
• Dependence: GPT models can generate high-quality text, but they can also
create a dependency on the technology, particularly when it comes to tasks
©2023 Page 24 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
such as content creation. This can lead to a loss of creativity, and a lack of
critical thinking.
• Decision making: GPT models can be used to make decisions, for example, to
generate responses for customer service chatbot or to generate investment
recommendations. However, GPT models are not perfect and they can make
mistakes, it is important to ensure that the decisions made by GPT models
are auditable and that there are mechanisms in place to detect and correct
errors.
OpenAI recognizes that there are still limitations with their current models. They
intend to make frequent updates to the model in order to address such limitations.
Additionally, by making ChatGPT easily accessible to users, OpenAI hopes to gather
valuable feedback on issues that they may not have previously been aware of.
©2023 Page 25 of 26
www.PDHonline.com PDH Course E666 www.PDHcenter.org
NLP and GPT are valuable tools that are revolutionizing the way we interact with
and understand human language. NLP provides the means to process and analyze
natural language, which is crucial in a wide range of industries such as customer
service, marketing, and finance. GPT, in particular, is a powerful language model
that is capable of generating high-quality text and performing well on a wide range
of language tasks with minimal task-specific fine-tuning.
However, the use of GPT and NLP also brings ethical considerations and limitations
that need to be taken into account, such as bias, misinformation, privacy,
dependence, and decision-making. To ensure the responsible use of GPT and NLP, it
is important to evaluate the performance and limitations of the model on the target
task, and to make sure the data used for fine-tuning the model is diverse and
unbiased. Additionally, it is important to monitor and evaluate the performance of
the model after it is deployed in production and to continuously improve the
model's performance by fine-tuning it on new data, and by incorporating feedback
from users.
Looking into the future, there is ongoing research to scale GPT to handle larger
inputs and outputs, to improve the explainability of GPT, to incorporate multi-modal
inputs, to develop GPT models for low-resource languages, and to incorporate GPT
in other AI applications. Additionally, further research is needed to address the
ethical considerations and limitations of GPT and NLP. With these advancements,
we can expect to see even more powerful and sophisticated NLP and GPT models
that can handle a wide range of language tasks and improve our ability to
understand and generate human language.
©2023 Page 26 of 26