---
title: "Total noob’s intro to Hugging Face Transformers"
description: "A beginner-oriented walkthrough of running Microsoft's Phi-2 language model with the Hugging Face Transformers library inside a JupyterLab notebook hosted on a Hugging Face Space with an NVIDIA A10G GPU."
url: "https://swe.quest/articles/total-noob-s-intro-to-hugging-face-transformers-c330cf4466509559"
canonical: "https://huggingface.co/blog/noob_intro_transformers"
source: "Hugging Face"
published: "2024-03-22"
difficulty: "easy"
kind: "How-to"
reading_minutes: 11
tags: ["llms","inference","python","machine-learning"]
---

# Total noob’s intro to Hugging Face Transformers

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-03-22, 11 min read, How-to. Original: [https://huggingface.co/blog/noob\_intro\_transformers](https://huggingface.co/blog/noob_intro_transformers)

## Summary

A beginner-oriented walkthrough of running Microsoft's Phi-2 language model with the Hugging Face Transformers library inside a JupyterLab notebook hosted on a Hugging Face Space with an NVIDIA A10G GPU. It explains foundational concepts along the way (libraries, the Hub, Spaces, classes, methods, tokenizers, instruction-tuned vs base models) and shows the minimal code: install torch and transformers, load the model and tokenizer with from\_pretrained, tokenize a prompt, call generate with max\_new\_tokens, and decode the output. Because Phi-2 is a base model, its output reads like autocomplete rather than a chat reply.

Written by swe.quest, not by the author.

**Difficulty:** Easy: no special background needed; explains what something is and why it matters

## Topics

- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)

## Keywords

Hugging Face Transformers, Hugging Face Spaces, Phi-2, PyTorch, JupyterLab, AutoModelForCausalLM

## Related posts

- [Hugging Face x LangChain : A new partner package](https://swe.quest/articles/hugging-face-x-langchain-a-new-partner-package-4a05b92542fbd2d8.md): Hugging Face · 2024-05-14 · Medium · 4 min read · LLMs, Python, Inference & serving, RAG & retrieval
  langchain-huggingface is a new Python partner package jointly maintained by Hugging Face and LangChain, replacing community-written integrations that had drifted out of date.
- [Hugging Face Text Generation Inference available for AWS Inferentia2](https://swe.quest/articles/hugging-face-text-generation-inference-available-for-aws-inferentia2-4404accc08bd48f1.md): Hugging Face · 2024-02-01 · Medium · 7 min read · Inference & serving, LLMs, Cloud platforms, Python
  Text Generation Inference (TGI) is now generally available on AWS Inferentia2 through Amazon SageMaker, offering an alternative to GPUs for serving open LLMs such as Llama and Mistral.
- [Deploy LLMs with Hugging Face Inference Endpoints](https://swe.quest/articles/deploy-llms-with-hugging-face-inference-endpoints-3facefc244b0efa0.md): Hugging Face · 2023-07-04 · Medium · 6 min read · Inference & serving, LLMs, Python, JavaScript
  Falcon 40B Instruct can be deployed to Hugging Face Inference Endpoints through the web UI by choosing a repository, cloud, region and instance.
- [Timm ❤️ Transformers: Use any timm model with transformers](https://swe.quest/articles/timm-transformers-use-any-timm-model-with-transformers-ae757824718fc026.md): Hugging Face · 2025-01-16 · Medium · 10 min read · Computer vision, Model training, Inference & serving, Python
  TimmWrapper lets any timm vision model load through Hugging Face transformers' Auto classes and pipeline API.
- [Hosting your Models and Datasets on Hugging Face Spaces using Streamlit](https://swe.quest/articles/hosting-your-models-and-datasets-on-hugging-face-spaces-using-streamlit-a8983f0b0bfbdd51.md): Hugging Face · 2021-10-05 · Medium · 3 min read · Python, Machine learning, Deployment
  Streamlit apps can showcase Hugging Face models and datasets and be hosted on Hugging Face Spaces.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
