explaingit

lordog/dive-into-llms

38,613Jupyter NotebookAudience · developerComplexity · 3/5QuietLicenseSetup · moderate

TLDR

Hands-on Jupyter Notebook tutorials teaching how large language models work, from fine-tuning and prompting to safety alignment and multimodal reasoning.

Mindmap

mindmap
  root((dive-into-llms))
    What it does
      Fine-tuning models
      Prompt engineering
      Model editing
    Key topics
      Watermarking text
      Jailbreak attacks
      Steganography
      RLHF alignment
    Format
      Jupyter Notebooks
      Interactive code
      Step-by-step learning
    Audience
      CS students
      AI researchers
      Developers

Things people build with this

USE CASE 1

Learn to fine-tune a pre-trained language model on your own task by following step-by-step code examples.

USE CASE 2

Understand how prompt engineering and chain-of-thought reasoning improve model outputs through interactive experiments.

USE CASE 3

Explore safety vulnerabilities like jailbreaks and steganography to build more robust AI systems.

USE CASE 4

Build multimodal applications that process both text and images using practical code walkthroughs.

Tech stack

PythonJupyter NotebookPyTorchTransformersNumPy

Getting it running

Difficulty · moderate Time to first run · 30min

PyTorch and Transformers library installation can be slow; GPU optional but recommended for some notebooks.

Free for non-commercial educational use; originated from university courses and is not licensed for commercial purposes.

In plain English

dive-into-llms is a hands-on programming tutorial series for learning how large language models (LLMs) work in practice. Large language models are the AI systems behind tools like ChatGPT, they are trained on vast amounts of text and can generate, understand, and reason about language. The project bridges the gap between abstract theory and real implementation, targeting students and researchers who want to move from reading about AI to actually building with it. The tutorials are organized as Jupyter Notebooks, interactive documents that mix explanatory text with runnable code, which you can step through cell by cell. Each chapter covers a distinct topic: fine-tuning a pre-trained model on a specific task, writing effective prompts and using chain-of-thought reasoning, editing what a model "knows", teaching a model to do mathematical reasoning, embedding invisible watermarks into generated text, understanding jailbreak attacks that trick models into ignoring safety guidelines, multimodal models that handle both text and images, GUI agents that control software interfaces on your behalf, safety alignment using reinforcement learning from human feedback (RLHF), and steganography (hiding secret messages inside generated text). The project originated from university courses at Shanghai Jiao Tong University and is free and non-commercial. A companion curriculum co-developed with Huawei's Ascend platform covers the full LLM development pipeline in greater depth. A computer science student, AI researcher, or developer wanting practical experience working with language models would use this repository. The tech stack is Python running in Jupyter Notebooks, using standard deep learning libraries typical of the field.

Copy-paste prompts

Prompt 1
Show me how to fine-tune a language model using the code in dive-into-llms chapter on fine-tuning.
Prompt 2
Explain the chain-of-thought prompting technique from dive-into-llms and give me a working example.
Prompt 3
Walk me through the RLHF (reinforcement learning from human feedback) implementation in dive-into-llms.
Prompt 4
How do I detect and prevent jailbreak attacks on language models using the methods shown in dive-into-llms?
Prompt 5
Show me the multimodal model code from dive-into-llms and explain how it handles text and images together.
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.