多数 Notebook 依赖云端平台或外部 API(OpenAI、Vertex AI 等),需自备账号与密钥;部分 Notebook 需从 Hugging Face 等下载模型权重;README 未列出统一的依赖版本,运行前需按各 Notebook 自行安装。

Transformers-for-NLP-and-Computer-Vision-3rd-Edition
Denis2054MIT长期未更新《Transformers for NLP and Computer Vision》第三版配套代码,用 Jupyter Notebook 演示 BERT、CLIP、DALL·E 3、GPT-4o、Gemini 等模型在 NLP、视觉和 RAG 任务中的实战用法。
Transformers 3rd Edition
README 未给出本地安装命令,直接在 Colab/Kaggle 等平台打开对应 Notebook 运行即可README 未说明具体显存或 GPU 型号要求;Notebook 提供 Colab、Kaggle、Gradient、SageMaker Studio Lab 等云端运行入口。
Transformers 第三版配套代码仓库,按章节提供可直接在 Colab 等平台运行的 Notebook
《Transformers for NLP and Computer Vision》第三版配套代码,用 Jupyter Notebook 演示 BERT、CLIP、DALL·E 3、GPT-4o、Gemini 等模型在 NLP、视觉和 RAG 任务中的实战用法。
核心能力
- 按 20 章组织 Notebook,覆盖 NLP 与计算机视觉
- 提供 Colab、Kaggle、Gradient、StudioLab 一键运行入口
- 包含 DeepSeek-R1、OpenAI o1 等新模型奖励 Notebook
- 涵盖 Hugging Face、OpenAI、Google Vertex AI 多平台示例
- 演示 RAG、BertViz、LIME、SHAP 等可解释与防幻觉方法
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Transformers for Natural Language Processing and Computer Vision: Take Generative AI and LLMs to the next level with Hugging Face, Google Vertex AI, ChatGPT, GPT-4V, and DALL-E 3 3rd Edition
by Denis Rothman
This repo is continually updated and upgraded.
Last updated: August 14, 2025
📝 For details on updates and improvements, see the Changelog.
🚩If you see anything that doesn't run as expected, raise an issue, and we'll work on it!
Look for 🐬 to explore new bonus notebooks such as and DeepSeek-R1 and OpenAI o1 reasoning models, Midjourney's API, Google Vertex AI Gemini's API, OpenAI asynchronous batch API calls!
Look for 🎏 to explore existing notebooks for the latest model or platform releases, such as OpenAI's latest models (GPT-4o and o1).
Look for 🛠 to run existing notebooks with new dependency versions and platform API constraints and tweaks.
Transformers-for-NLP-and-Computer-Vision-3rd-Edition
This is the code repository for Transformers for Natural Language Processing and Computer Vision, published by Packt.
Explore Generative AI and Large Language Models with Hugging Face, ChatGPT, GPT-4V, and DALL-E 3
About the book
Transformers for Natural Language Processing and Computer Vision, Third Edition, explores Large Language Model (LLM) architectures, applications, and various platforms (Hugging Face, OpenAI, and Google Vertex AI) used for Natural Language Processing (NLP) and Computer Vision (CV).
Dive into generative vision transformers and multimodal model architectures and build applications, such as image and video-to-text classifiers. Go further by combining different models and platforms and learning about AI agent replication.
What you will learn
- Learn how to pretrain and fine-tune LLMs
- Learn how to work with multiple platforms, such as Hugging Face, OpenAI, and Google Vertex AI
- Learn about different tokenizers and the best practices for preprocessing language data
- Implement Retrieval Augmented Generation and rules bases to mitigate hallucinations
- Visualize transformer model activity for deeper insights using BertViz, LIME, and SHAP
- Create and implement cross-platform chained models, such as HuggingGPT
- Go in-depth into vision transformers with CLIP, DALL-E 2, DALL-E 3, and GPT-4V
Table of Contents
Chapters
- What Are Transformers?
- Getting Started with the Architecture of the Transformer Model
- Emergent vs Downstream Tasks: The Unseen Depths of Transformers
- Advancements in Translations with Google Trax, Google Translate, and Gemini
- Diving into Fine-Tuning through BERT
- Pretraining a Transformer from Scratch through RoBERTa
- The Generative AI Revolution with ChatGPT
- Fine-Tuning OpenAI GPT Models
- Shattering the Black Box with Interpretable Tools
- Investigating the Role of Tokenizers in Shaping Transformer Models
- Leveraging LLM Embeddings as an Alternative to Fine-Tuning
- Toward Syntax-Free Semantic Role Labeling with ChatGPT and GPT-4
- Summarization with T5 and ChatGPT
- Exploring Cutting-Edge LLMs with Vertex AI and PaLM 2
- Guarding the Giants: Mitigating Risks in Large Language Models
- Beyond Text: Vision Transformers in the Dawn of Revolutionary AI
- Transcending the Image-Text Boundary with Stable Diffusion
- Hugging Face AutoTrain: Training Vision Models without Coding
- On the Road to Functional AGI with HuggingGPT and its Peers
- Beyond Human-Designed Prompts with Generative Ideation
Appendix
Appendix: Answers to the Questions
Platforms
You can run the notebooks directly from the table below:
| Chapter | Colab | Kaggle | Gradient | StudioLab |
|---|---|---|---|---|
| Part I The Foundations of Transformer Models | ||||
| Chapter 1: What are Transformers? | ||||
| 🛠O_1_and_Accelerators.ipynbChatGPT_Plus_writes_and_explains_AI.ipynb | ||||
| Getting started with DeepSeek-R1 Reasoning models. Integrated into HuggingFace Hub and Together. | ||||
| 🐬DeepSeek_Hugging_Face.ipynb | ||||
| Chapter 2: Getting Started with the Architecture of the Transformer Model | ||||
| 🛠Multi_Head_Attention_Sub_Layer.ipynbpositional_encoding.ipynb | ||||
| Explaining DeepSeek's Training innovations; Part 1: RL | ||||
| 🐬DeepSeek_R1_Zero_RL.ipynb | ||||
| Explaining DeepSeek's Training innovations; Part 2: RoPE | ||||
| 🐬DeepSeek_attention_head_RoPE.ipynb | ||||
| Chapter 3: Emergent vs Downstream Tasks: the Unseen Depths of Transformers | ||||
| From_training_to_emergence.ipynbTransformer_tasks_with_Hugging_Face.ipynb | ||||
| Chapter 4: Advancements in Translations with Google Trax, Google Translate, and Google Bard | ||||
| WMT_translations.ipynbTrax_Google_Translate.ipynb | ||||
| Chapter 5: Diving into Fine-Tuning through BERT | ||||
| BERT_Fine_Tuning_Sentence_Classification_GPU.ipynb | ||||
| Chapter 6: Pretraining a Transformer from Scratch through RoBERTa | ||||
| 🎏 KantaiBERT.ipynb🎏🛠 Customer_Support_for_X.ipynb | ||||
| Part II: The Rise of Suprahuman NLP | ||||
| Chapter 7: The Generative AI Revolution with ChatGPT | ||||
| OpenAI_Models.ipynbOpenAI_GPT_4_Assistant.ipynb🎏Getting_Started_GPT_4_API.ipynb(GPT-4o)🎏GPT_4_RAG.ipynb(GPT-4o) | ||||
| OpenAI Reasoning models: the o1 API | ||||
| 🐬OpenAI_Reasoning_models_o1_API.ipynb | ||||
| OpenAI Reasoning models: the o1-preview API | ||||
| 🐬OpenAI_Reasoning_models_o3_API.ipynb | ||||
| Chapter 8: Fine-tuning OpenAI Models | ||||
| Fine_tuning_OpenAI_Models.ipynb🎏Fine_tuning_GPT_4o_mini_SQuAd.ipynb | ||||
| Fine-Tuning GPT-4.1 | ||||
| 🎏Fine_tuning_GPT_4.1_mini_SQuAd.ipynb | ||||
| 🐬RAG as an alternative to fine-tuning: Building Scalable Knowledge-based RAG-drive Generative AI | ||||
| Click here to access an open-source library to implement RAG | ||||
| Chapter 9: Shattering the Black Box with Interpretable tools | ||||
| BertViz_Interactive.ipynbHugging_Face_SHAP.ipynb | ||||
| Chapter 10: Investigating the Role of Tokenizers in Shaping Transformer Models | ||||
| Tokenizers.ipynbSub_word_tokenizers.ipynb🛠Exploring_tokenizers.ipynb | ||||
| Chapter 11: Leveraging LLM Embeddings as an Alternative to Fine-Tuning | ||||
| 🛠Embedding_with_NLKT_Gensim.ipynb🎏Question_answering_with_embeddings.ipynb🛠Transfer_Learning_with_Ada_Embeddings.ipynb | ||||
| Chapter 12: Towards Syntax-Free Semantic Role Labeling with BERT and OpenAI's ChatGPT | ||||
| Semantic_Role_Labeling_GPT-4.ipynb | ||||
| Chapter 13: Summarization with T5 and ChatGPT | ||||
| 🛠Summerizing_Text_T5.ipynbSummarizing_ChatGPT.ipynb | ||||
| Chapter 14: Exploring Cutting-Edge NLP with Google Vertex AI(PaLM and🐬Gemini with gemini-1.5-flash-001 | ||||
| Google_Vertex_AI.ipynb🐬Google_Vertex_AI_Gemini.ipynb | ||||
| Gemini 2.5 Flash showcase of Generative AI tasks | ||||
| 🐬Google_Gemini_2.5_Flash.ipynb | ||||
| Chapter 15: Guarding the Giants: Mitigating Risks in Large Language Models< | ||||
| 🎏Auto_Big_bench.ipynb(GPT-4o,synchronous)🎏Auto_Big_bench.ipynb(GPT-4o-mini,synchronous)🐬GPT API Speed++ with Asynchronous Batch Calls!🛠WandB_Prompts_Quickstart.ipynbEncoder_decoder_transformer.ipynbMitigating_Generative_AI.ipynb | ||||
| Part III: Generative Computer Vision: A New Way to See the World | ||||
| Chapter 16: Vision Transformers in the Dawn of Revolutionary AI | ||||
| ViT_CLIP.ipynbGetting_Started_DALL_E_API.ipynb🎏GPT-4V.ipynb(GPT-4o) | ||||
| Chapter 17: Transcending the Image-Text Boundary with Stable Diffusion | ||||
| Stable_Diffusion_Keras.ipynbStable__Vision_Stability_AI.ipynbStable__Vision_Stability_AI_Animation.ipynbText_to_video_synthesis.ipynbTimeSformer.ipynb | ||||
| Stable Diffusion with Hugging Face | ||||
| 🐬Stable_Diffusion_Hugging_Face.ipynb | ||||
| Chapter 18: Automated Vision Transformer Training | ||||
| 🛠Hugging_Face_AutoTrain.ipynb | [ |