Code repository for the book The Complete Hugging Face Blueprint by James Karanja Maina.
This repository contains all the code examples, projects, and resources used in "The Complete Hugging Face Blueprint" book. The book provides a comprehensive guide to using Hugging Face's ecosystem for natural language processing, computer vision, and other machine learning tasks.
The repository is organized by chapters, with each chapter containing lesson files that correspond to specific sections in the book:
- Chapter 1-25: Individual chapter folders containing Python scripts for each lesson
- Models: Various fine-tuned models created throughout the book
bert-sentiment-imdb
: BERT model fine-tuned for sentiment analysis on IMDB datasetlegal-gpt2
: GPT-2 model fine-tuned on legal textspokemon_fine_tuned
: Stable Diffusion model fine-tuned on Pokemon imagesvit-beans-classifier
: Vision Transformer model for classifying bean images- And many more!
- Utilities: Helper functions and common code used across chapters
- Images: Image files used in examples and demonstrations
Throughout the book, you'll build several practical projects:
- Text Classification: Fine-tuning models for sentiment analysis and text categorization
- Language Generation: Creating specialized language models for specific domains
- Image Classification: Building and training vision models for image recognition tasks
- Text-to-Image Generation: Working with diffusion models like Stable Diffusion
- Model Optimization: Techniques for pruning and optimizing transformer models
- Model Deployment: Methods for serving models in production environments
- Python 3.8 or higher
- PyTorch
- Transformers library
- Datasets library
- Diffusers library (for image generation chapters)
The repository includes a virtual environment (hf-env
) with all necessary dependencies. To create a similar environment:
python -m venv hf-env
source hf-env/bin/activate # On Windows: hf-env\Scripts\activate
pip install -r requirements.txt
- Chapter 1-7: Fundamentals of Hugging Face ecosystem and transformer models
- Chapter 8-13: Advanced NLP tasks and model fine-tuning
- Chapter 14-19: Computer vision and multimodal models
- Chapter 20-25: Diffusion models, deployment, and production considerations
The code examples use a combination of:
- Pre-trained models from the Hugging Face Hub
- Custom fine-tuned models created during the lessons
- Public datasets for training and evaluation
- Synthetic data generated for specific examples
- Hugging Face documentation: https://huggingface.co/docs
- Transformers library: https://github.com/huggingface/transformers
- Datasets library: https://github.com/huggingface/datasets
- Diffusers library: https://github.com/huggingface/diffusers
This project contains code examples for educational purposes. Please refer to the book for usage rights and restrictions.
James Karanja Maina
Happy learning with Hugging Face!