Overview

1 Introduction to Hugging Face

Hugging Face is an open, community-driven platform for building, sharing, and deploying state-of-the-art machine learning across natural language, vision, and audio. It centralizes pre-trained models and datasets so developers can focus on shipping AI-powered applications instead of training models from scratch, aligning with a strong open-source philosophy. The chapter introduces the core ecosystem—Transformers, the Model Hub, Spaces, and Gradio—and previews later topics like building LLM apps, rapid prototyping, privacy-preserving workflows, tool-using agents, and connecting assistants to external data.

The Transformers library provides easy access to pre-trained models through friendly APIs such as pipelines, enabling tasks like text classification, translation, summarization, and named entity recognition with minimal code. The Model Hub hosts a vast catalog of models, complete with searchable filters, examples, and ready-to-use snippets. Many models can be tried instantly via a hosted inference interface, and developers can either call hosted endpoints for zero-setup inference or download weights to run locally with Transformers—making it straightforward to move from exploration to integration.

Gradio adds a fast path from model to user experience by generating interactive web interfaces with just a few lines of Python, and it integrates seamlessly with Spaces for sharing demos publicly. The chapter also lays out a practical mental model for using the platform: start with a concrete need, discover candidate models on the Hub, consult model cards for guidance, choose between hosted inference or local execution, and deliver results. Overall, Hugging Face streamlines the journey from problem to production-ready AI, with subsequent chapters diving deeper into customization and advanced application patterns.

The result of the sentiment analysis
Exploring the pre-trained models hosted on Hugging Face hub
You can test the model directly on Hugging Face hub using the Hosted inference API
Performing object detection using my uploaded image
Locating the “</> Use in Transformers” button
Using the model using the transformers library
Gradio provides a customizable UI for your ML projects
Viewing the result of the converted image
A visual mental model showing Hugging Face’s core process

Summary

  • The Transformers Library is a Python package that contains open-source implementation of the Transformer architecture models for text, image, and audio tasks.
  • In Hugging Face's Transformers library, a pipeline is a high-level, user-friendly API that simplifies the process of building and using complex natural language processing (NLP) workflows.
  • The Hugging Face Hub’s Models page hosts many pre-trained models for a wide variety of machine learning tasks.
  • Gradio is a Python library that creates a Web UI that you can use to bind to your machine learning models, making it easy for you to test your models without spending time building the UI.
  • Hugging Face isn’t just a model repository. It’s a complete AI problem-solving pipeline that systematically moves users from problems to solution.

FAQ

What is Hugging Face and what is it known for?Hugging Face is an open AI community and platform focused on building, training, and deploying open-source machine learning models. It’s known for state-of-the-art models across NLP, computer vision, and audio, the Transformers library, the Model and Dataset Hubs, Spaces for hosting apps, and the Gradio UI library. Its philosophy emphasizes open-source contributions.
What is the Hugging Face Transformers library?Transformers is a Python library that provides open-source implementations of Transformer-based models for text, image, and audio tasks. It offers simple APIs to load and run pre-trained, state-of-the-art models, so developers don’t need to train from scratch.
What is a pipeline in Transformers and why use it?A pipeline is a high-level API that wraps common ML tasks (like text classification, NER, translation, summarization, object detection) into a few lines of code. It abstracts preprocessing, model inference, and postprocessing so you can focus on results rather than plumbing.
How do I run a quick sentiment analysis with Transformers?- Import and create a pipeline: pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english").
- Call it with your text; it returns a label (e.g., POSITIVE/NEGATIVE) and a confidence score.
- You can optionally wrap the result in a Pandas DataFrame for display. The chapter demonstrates this using an IMDB movie review.
What is the Hugging Face Model Hub and how do I discover models?The Model Hub hosts over a million pre-trained models in task-specific repositories. You can search and filter by task (e.g., sentiment analysis), architecture (e.g., BERT, DETR), language, and performance metrics. Each model page provides details and ready-to-use code.
What is a Model Card?A Model Card is the documentation page for each model. It includes usage examples, code snippets, training details, benchmarks, intended use cases, and often limitations or ethical considerations—serving as the bridge from discovery to implementation.
What is the Hosted Inference API and when should I use it?The Hosted Inference API lets you test and run models via simple HTTP requests or directly in the browser using built-in widgets—no setup required. It’s ideal for quick evaluation, demos, or production scenarios where you prefer managed infrastructure that auto-scales.
How can I try and then use the facebook/detr-resnet-50 object detection model?- In-browser: Open the model page, drag-and-drop an image, and view detected objects with confidence scores using the Hosted Inference API.
- In code: Click “Use in Transformers” on the model page to copy sample code, then run an object-detection pipeline with model="facebook/detr-resnet-50".
What is Gradio and how does it help share models?Gradio is an open-source Python library for creating web UIs around functions and ML models with minimal code. You define inputs/outputs (e.g., Image in, image out), launch locally, and share with users. It integrates seamlessly with Hugging Face Spaces for public hosting.
What is Hugging Face’s mental model from problem to results?- Step 1: User need (e.g., classify sentiment, translate text).
- Step 2: Discover a model on the Model Hub using search and filters.
- Step 3: Use the Model Card for guidance and code snippets.
- Step 4: Choose execution path: Inference API (hosted) or local download via Transformers.
- Step 5: Get results (e.g., {"label":"POSITIVE","score":...}) and integrate into your app.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Hugging Face in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Hugging Face in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Hugging Face in Action ebook for free