explaingit

nlp-with-transformers/notebooks

4,770Jupyter NotebookAudience · developerComplexity · 3/5Setup · moderate

TLDR

All code examples from the O'Reilly book Natural Language Processing with Transformers, organized as runnable Jupyter notebooks covering classification, summarization, translation, question answering, and more.

Mindmap

mindmap
  root((NLP with Transformers))
    Topics
      Text classification
      Named entity recognition
      Summarization
      Translation
      Question answering
      Text generation
    Platforms
      Google Colab
      Kaggle
      Amazon SageMaker
      Local install
    Tech
      Python
      Hugging Face
      Jupyter Notebooks
    Audience
      Book readers
      NLP learners
      AI practitioners
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Follow along with the NLP with Transformers book by running each chapter's notebook on free Google Colab GPU

USE CASE 2

Fine-tune a transformer model for text classification on your own dataset using the provided notebook as a template

USE CASE 3

Build a question-answering or text summarization system by adapting the corresponding chapter notebook

USE CASE 4

Learn to make large AI models more efficient using the model compression techniques in the dedicated chapter

Tech stack

PythonJupyter NotebookHugging Face TransformersGoogle Colab

Getting it running

Difficulty · moderate Time to first run · 30min

GPU strongly recommended, easiest path is one-click open in Google Colab from the README links.

In plain English

This repository holds all the code examples from the O'Reilly book "Natural Language Processing with Transformers." The book teaches how to work with transformer models, a category of AI model that has become the foundation for most modern language tools including chatbots, translation systems, and text summarizers. The code is organized into Jupyter notebooks, which are interactive documents that mix written explanation with runnable Python code. Each notebook corresponds to a chapter of the book. The topics covered include text classification, named entity recognition (identifying names, places, and organizations in text), text generation, summarization, question answering, translation, and making models more efficient. There is also a chapter on training large language models from scratch. The notebooks are self-contained, meaning a reader can open one and run through it without needing to read the earlier ones first. The notebooks are designed to run on cloud platforms such as Google Colab or Kaggle, both of which provide free access to a GPU. A GPU is strongly recommended because most of the examples involve running or fine-tuning large AI models that would take impractically long on a regular laptop processor. Each chapter in the README has direct links to open the corresponding notebook on Colab, Kaggle, Gradient, and Amazon SageMaker Studio Lab with a single click. Local installation is also possible for those with a capable machine. The repository includes setup instructions and a requirements file listing the necessary Python packages. This is a companion resource to a published book rather than a standalone tool. It is most useful for someone reading the book who wants to run the examples themselves, or for anyone looking for practical, well-explained code covering a broad range of natural language processing tasks using transformer models.

Copy-paste prompts

Prompt 1
I am following the NLP with Transformers notebooks and want to fine-tune a BERT model for sentiment analysis on my own CSV. Show me how to modify the text classification notebook to load my custom dataset.
Prompt 2
The transformer summarization notebook from nlp-with-transformers is running out of GPU memory on Colab. How do I reduce batch size and use gradient accumulation to fix it?
Prompt 3
Help me adapt the named entity recognition notebook to identify custom entity types like product names and prices in e-commerce reviews.
Prompt 4
I want to run the translation notebook locally instead of on Colab. What GPU do I need and how do I set up the Python environment?
Open on GitHub → Explain another repo

← nlp-with-transformers on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.