Skip to content

antoniovasssss/simple-llm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Simple LLM Demo

A beginner-friendly demonstration of text generation using a small language model (DistilGPT-2) via Hugging Face Transformers.

What It Does

Uses DistilGPT-2 (82M parameters) to generate text from a given prompt. Two scripts are included:

File Description
intro_transformer.py Minimal example — loads the model and generates text from a single hardcoded prompt
intro_transformer_enhanced.py Full demo with three modes: batch prompts, interactive input, and a tokenization explainer

Requirements

  • Python 3.8+
  • PyTorch
  • Hugging Face Transformers

Install dependencies:

pip install torch transformers

How to Run

Basic script

python intro_transformer.py

Generates a continuation of "Once upon a time" and prints it to the console.

Enhanced script

python intro_transformer_enhanced.py

You'll be prompted to choose a mode:

1. Run basic demonstration   # Cycles through 3 example prompts
2. Interactive mode          # Enter your own prompts in a loop
3. Explain the process       # Shows tokenization step-by-step

Note: The model downloads automatically on first run (~300MB). Subsequent runs use the cached version.

How It Works

Your text  →  Tokenizer  →  Token IDs  →  DistilGPT-2  →  Predicted tokens  →  Output text

The model predicts the most likely next token repeatedly until it hits the max_length limit. It runs entirely on CPU — no GPU required.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages