NLP Transformer Class Notes
NLP Transformer Class Notes
Ashish Patel • Principal Research Scientist • [email protected] Abonia Sojasingarayar • Machine Learning Scientist • [email protected] Updated: 2023-02
Large Language Models : : CHEAT SHEET
Text Generation: ChatGPT can generate text based on a
Attention Mechanisms Evaluating LLMs prompt or seed text. Example: Challenges and limitations
Self-Attention:
with LLMs
•Accuracy measures the proportion of correctly classified Human : Write a short story about a magical world.
•A mechanism that allows a sequence to weigh the • One of the main challenges with
instances out of all instances. This metric is commonly ChatGPT: Once upon a time, in a land far away, there
importance of all other elements in the sequence when LLMs is the potential for biased or
used for text classification tasks such as sentiment was a magical world filled with wonder and
computing a representation for each element. offensive language, as the models
analysis, where the goal is to correctly classify a text as enchantment. The sky was always a brilliant shade of
•Can capture relationships between different elements in the positive, negative, or neutral. purple, and the stars twinkled like diamonds in the sky.
learn from the patterns found in the
sequence, making it well-suited for tasks that require training data.
The people of this world possessed magical powers that
modeling long-range dependencies. they used to create incredible wonders and to help • Unethical considerations, such as
•F1-score is a metric that takes into account both
•Popularized by the Transformer model. precision and recall. Precision is the proportion of true those in need. One day, a young woman discovered that gender and racial biases.
she too had magical powers, and set out on an • Amount of computational resources
positive results out of all predicted positive results, while
incredible journey to explore the wonders of this needed to train and run LLMs, which
Multi-Head Attention: recall is the proportion of true positive results out of all
magical world and to hone her skills. can be expensive and energy-
•A variation of self-attention where the attention mechanism actual positive results. The F1-score is the harmonic mean
intensive.
is applied multiple times in parallel with different sets of of precision and recall, and it provides a balanced
weights. measure of model performance on text classification, Summarization: ChatGPT can summarize a long text or • Handling out-of-vocabulary words
•Allows the model to attend to different aspects of the input question answering, and other tasks. article. Example: • Improving interpretability. While
sequence, improving its ability to capture complex patterns large language models have shown
impressive performance on a variety
and dependencies. •Perplexity : It measures how well a language model Human : Please summarize this article about the
of NLP tasks, they may not perform
•Each "head" produces a separate output that is predicts the next word in a sequence. The lower the benefits of exercise.
as well on specific tasks, such as
concatenated and linearly transformed to produce the final perplexity, the better the model is at predicting the next ChatGPT: The article discusses the various physical and those that require a deeper
output. word. Perplexity is calculated as 2 to the power of the mental health benefits of exercise, including improved understanding of the underlying
•Also commonly used in the Transformer model. cross-entropy, which is a measure of how well the cardiovascular health, stronger muscles and bones, context.
model's predicted probabilities match the true better weight management, and reduced stress and
probabilities of the next word in the sequence.Also text anxiety. It also highlights the importance of finding an
can be evaluated using metrics such as BLEU or ROUGE
scores.
exercise routine that is enjoyable and sustainable.
Applications of LLMs
Translation: ChatGPT can translate text from one • LLMs are used in a wide range of
language to another. Example: applications, including language
translation, chatbots, content
Example - ChatGPT Translate this sentence from English to Spanish. "The creation, and text
sky is blue." summarization.
ChatGPT is a large language model developed ChatGPT: El cielo es azul.
by OpenAI that has been trained on a diverse • They can also be used to improve
range of internet text, including articles, forums, search engines, voice assistants,
and social media. This training allows ChatGPT and virtual assistants.
to generate human-like text and answer a wide Tools&Libraries support LLMs
variety of questions on many topics.
a. Popular NLP libraries, such as TensorFlow, PyTorch,
Use Cases ChatGPT spaCy, Hugging Face Transformers, AllenNLP,OpenAI
GPT-3 API, AllenAI's ELMO, spaCy Transformers etc Future of LLMs
Question Answering: ChatGPT can answer factual provide tools for working with large language models.
questions based on the information it has been These libraries allow for easy fine-tuning and The future of LLMs is promising, with ongoing research
trained on. Example: deployment of models. focused on improving their accuracy, reducing bias, and
making them more accessible and energy-efficient.
Human : What is the capital of France? b. Some large language models, such as GPT-3, provide As the demand for AI-driven applications continues to
ChatGPT: The capital of France is Paris. APIs for access to their models. This can simplify the grow, LLMs will play an increasingly important role in
process of integrating a large language model into a shaping the future of human-machine interaction.
Conversational: ChatGPT can engage in a real-world application.
conversation with a user. Example:
Ashish Patel • Principal Research Scientist • [email protected] Abonia Sojasingarayar • Machine Learning Scientist • [email protected] Updated: 2023-02
Large Language Models : : CHEAT SHEET
Transformer Architecture
GPT Architecture
BERT Architecture
Ashish Patel • Principal Research Scientist • [email protected] Abonia Sojasingarayar • Machine Learning Scientist • [email protected] Updated: 2023-02