Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a22b67d
second commit
sinanuozdemir Nov 17, 2021
fd35acf
added comments
sinanuozdemir Nov 18, 2021
214bff1
BERT notes
sinanuozdemir Nov 18, 2021
26875d0
xlnet comments
sinanuozdemir Nov 18, 2021
5af49b4
gitignore and disaster data
sinanuozdemir Nov 18, 2021
1a89f5b
oreilly image and new transformer
sinanuozdemir Nov 18, 2021
a822a5a
Update README.md
sinanuozdemir Nov 18, 2021
4d503ee
gpt final comments
sinanuozdemir Nov 18, 2021
977e095
add requirements file
sinanuozdemir Nov 19, 2021
b08d7d0
added a cell
sinanuozdemir Nov 19, 2021
ddf49c3
updates to BERT notebook
sinanuozdemir Nov 19, 2021
fa86f7e
updates to BERT notebook
sinanuozdemir Nov 19, 2021
1605bbb
new notebooks
sinanuozdemir May 24, 2022
bd47779
updates for class
sinanuozdemir Jan 10, 2023
caf310e
using new eval
sinanuozdemir Jan 10, 2023
1bbaa20
updates for class
sinanuozdemir Jan 10, 2023
6447a17
final changes
sinanuozdemir Jan 11, 2023
1204888
typo in xlnet
sinanuozdemir Jan 11, 2023
3ff652c
added a note
sinanuozdemir Jan 11, 2023
0895614
changes from class and updated req just in case
sinanuozdemir Jan 11, 2023
6ffd2d9
updates
sinanuozdemir Nov 19, 2023
fe67577
updates
sinanuozdemir Nov 19, 2023
c3e7139
updates
sinanuozdemir Nov 19, 2023
b54b175
updates
sinanuozdemir Nov 19, 2023
3ef2a1f
updates for 8.6
sinanuozdemir Aug 4, 2024
f8cdcda
final tweak
sinanuozdemir Aug 6, 2024
869e942
Update README.md
sinanuozdemir Dec 16, 2024
b4f9504
updates for 12/17
sinanuozdemir Dec 16, 2024
1a9453c
updates for 12/17
sinanuozdemir Dec 16, 2024
311d206
add clip notebook
sinanuozdemir Dec 17, 2024
660a4f2
Update README.md
sinanuozdemir Dec 17, 2024
5f8ed73
Update requirements.txt
sinanuozdemir Dec 17, 2024
87214f4
Update README.md
sinanuozdemir Dec 17, 2024
ef96c4f
added fine tuning embedding
sinanuozdemir Dec 17, 2024
46ba2cb
added fine tuning embedding
sinanuozdemir Dec 17, 2024
cafef5e
Update README.md
sinanuozdemir Mar 20, 2025
0902a20
update embedding notebook
sinanuozdemir May 8, 2025
311bf47
notebook fix
sinanuozdemir Jul 23, 2025
1ed73a4
notebook fix
sinanuozdemir Jul 23, 2025
ca05c7d
Ignore flicker_images folder
sinanuozdemir Jul 23, 2025
9c8cec1
Remove flicker_images from repository
sinanuozdemir Jul 23, 2025
71e776e
updated readme
sinanuozdemir Jul 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.ipynb filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
add filter=lfs diff=lfs merge=lfs -text
other filter=lfs diff=lfs merge=lfs -text
*.csv filter=lfs diff=lfs merge=lfs -text
\# filter=lfs diff=lfs merge=lfs -text
file filter=lfs diff=lfs merge=lfs -text
types filter=lfs diff=lfs merge=lfs -text
as filter=lfs diff=lfs merge=lfs -text
needed filter=lfs diff=lfs merge=lfs -text
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.env
.DS_store
.ipynb_checkpoints/
notebooks/t5_summary_results
notebooks/image_captioning
notebooks/english_to_latex
notebooks/lightning_logs
notebooks/toxic
notebooks/xlnet_clf/
notebooks/calculus/
notebooks/calculus_english_to_latex/
notebooks/v2_image_captioning/
notebooks/snips_clf/
notebooks/snips_tok_clf/
data/reviews.csv
data/cached*
notebooks/wandb/
notebooks/pre_trained_english_to_latex/
notebooks/pre_trained/
notebooks/bert_clf_results/
data/flicker_images/
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
![oreilly-logo](images/oreilly.png)

# Transformer Architectures for Generative AI

This repository contains code for the [O'Reilly Live Online Training for "Transformer Architectures for Generative AI"](https://learning.oreilly.com/live-events/transformer-architectures-for-generative-ai/0642572010589)

This course is designed to provide a deep understanding of transformer architectures and their revolutionary impact on both natural language processing (NLP) and vision tasks. This course is crucial for professionals looking to stay at the forefront of AI advancements, as transformers are now the cornerstone of many state-of-the-art models. By combining theory with practical exercises, participants will learn how to harness the power of transformers to tackle complex problems in text, image, and multimodal AI.

## Notebooks

### Introduction to LLMs

1. BERT - the beginnings of LLMs
- [Introduction to BERT](notebooks/intro_to_bert.ipynb)
2. T5 - the beginnings of instructional alignment
- [Off the shelf NLP with T5](notebooks/t5.ipynb)
3. GPT - How LLMs learned to talk
- [Introduction to GPT](notebooks/intro_to_gpt.ipynb)
4. Multimodal LLMs
- [Image Captioning with Vision Transformers](https://colab.research.google.com/drive/1OQlX_cD4mVo8vB3A4co1JIfl9Vt7rhzN?usp=sharing)
5. [Inspecting LLM token embeddings](notebooks/LLM Embeddings.ipynb) - Explore how different attention mechanisms lead to different token embeddings

### Advanced LLMs

**LLM Embedding**

- [Rivaling OpenAI embeddings with fine-tuning](https://colab.research.google.com/drive/1FOr9hgMEcTa8UJJSuKjoHpohVb-Qz-FJ?usp=sharing) - Fine-tune Embeddings with Synthetic Data

**LLM Classification**

- [`bert_app_review.ipynb`](notebooks/bert_app_review.ipynb): Fine-tuning a BERT model for app review classification.
- [`openai_app_review_fine_tuning.ipynb`](notebooks/openai_app_review_fine_tuning.ipynb): Fine-tuning OpenAI models for app review classification.

**Multimodal**

- [Stock Image Search](https://colab.research.google.com/drive/1aUz0FKQDSAyXyhRyvkkRsSy7S30mpRJc?usp=sharing) - Using a CLIP model to build an image search system

- Visual Q/A

- [`constructing_a_vqa_system.ipynb`](notebooks/constructing_a_vqa_system.ipynb): Step-by-step guide to constructing a Visual Question Answering (VQA) system using GPT-2 and Vision Transformer.
- [`using_our_vqa.ipynb`](notebooks/using_our_vqa.ipynb): Using the VQA system built in the previous notebook.


**SAWYER - Instructional Fine-tuning**

- [`SAWYER_LLAMA_SFT.ipynb`](notebooks/SAWYER_LLAMA_SFT.ipynb): Fine-tuning the Llama-3 model to create the SAWYER bot.
- [`SAWYER_Reward_Model.ipynb`](notebooks/SAWYER_Reward_Model.ipynb): Training a reward model from human preferences for the SAWYER bot.
- [`SAWYER_RLF.ipynb`](notebooks/SAWYER_RLF.ipynb): Applying Reinforcement Learning from Human Feedback (RLHF) to align the SAWYER bot.
- [`SAWYER_USE_SAWYER.ipynb`](notebooks/SAWYER_USE_SAWYER.ipynb): Using the SAWYER bot.

**Distillation / Speculative Decoding / Caching**

- [Go Emotion Distillation](notebooks/go_emotion_distillation.ipynb): Exploring knowledge distillation techniques for transformer models.

- [Speculative Decoding](https://colab.research.google.com/drive/1QXqUjgMLUbAqXzGc8uBWJ5t4BEtJQbWh?usp=sharing) - Using an assistant model to aid token decoding

- [Prompt Caching Llama 3](https://colab.research.google.com/drive/1LlocxmN6adI-bFeT2dGGa4U2zkku77o7?usp=sharing) - Replicating prompt caching with HuggingFace tools

**Agents / RAG**

- [RAG Retrieval](notebooks/RAG_Retrieval.ipynb): An introduction to vector databases, embeddings, and retrieval
- [Evaluating Tool Selection](notebooks/agent_positional_bias_tools.ipynb) - Calculating the accuracy of tool selection between different LLMs and quantifying the positional bias present in auto-regressive LLMs


**Probing**

- [Probing Chess Playing LLMs](https://colab.research.google.com/drive/114turFLNxLJXiIseDWl1BDJmont0VD8h?usp=sharing)

- There are over a dozen notebooks for the birth year/death year probing example so I will only share a few key ones here:

- [Llama-3 8B Instruct with prompt "Who is {NAME}"](https://colab.research.google.com/drive/1e1d9fATVjVun-_tPj4vS_DSTGaIfxs01?usp=sharing)
- [BERT-large-cased no prompt](https://colab.research.google.com/drive/1cizgoh1J6Y-DHBrOkNTFo9Y1CypjwuQM?usp=sharing)
- [Mistral-7B-Instruct-v0.3 with prompt "Who is {NAME}"](https://colab.research.google.com/drive/1VL3betxqVZ_H3_8XmLbjE0hEjaoy-HPV?usp=sharing)


## Instructor

**Sinan Ozdemir** is founder and CTO of LoopGenius, where he uses state-of-the-art AI to help people create and run their businesses. He has lectured in data science at Johns Hopkins University and authored multiple books, videos and numerous online courses on data science, machine learning, and generative AI. He also founded the recently acquired Kylie.ai, an enterprise-grade conversational AI platform with RPA capabilities. Sinan most recently published Quick Guide to Large Language Models, and launched a podcast audio series, AI Unveiled. Ozdemir holds a master’s degree in pure mathematics from Johns Hopkins University.
Loading