How sakthi82/ai-fundamentals works
This repository is a collection of runnable AI-learning demonstrations, not a single language-model application. The main workflow is to run a script and inspect its printed measurements or generated text; the scripts do not call one another. GPT-2-backed demonstrations explore tokenization, embeddings, attention, scoring, generation, and hallucination, while two independent scripts train tiny models from scratch. README-described links establish the script capabilities; source excerpts confirm the sampled implementations.
Main entry points: 03_attention.py Inspect attention · 01_tokenize.py Tokenize text · 02_embeddings.py Inspect embeddings · 04_predict_next_token.py Score next token
Components 14
GPT-2 explorations
- Tokenize text
01_tokenize.py - Inspect embeddings
02_embeddings.py - Inspect attention
03_attention.py - Score next token
04_predict_next_token.py - Sample token loop
05_manual_generation_loop.py
From-scratch learning
- Tiny Transformer
06_train_tiny_transformer_from_scratch.py - Train and generate
06_train_tiny_transformer_from_scratch.py - Tiny language model
08_watch_it_learn.py - Learning experiments
08_watch_it_learn.py
Hallucination analysis
- Measure uncertainty
07_why_it_hallucinates.py
Other components
- Learner
- Pretrained GPT-2
- Printed results
- Attention heatmap
Connections 25
- Learner → Tokenize text: runs
README.md - Learner → Inspect embeddings: runs
README.md - Learner → Inspect attention: runs
README.md - Learner → Score next token: runs
README.md - Learner → Sample token loop: runs
README.md - Learner → Train and generate: runs
README.md - Learner → Measure uncertainty: runs
README.md - Learner → Learning experiments: runs
README.md - Tokenize text → Pretrained GPT-2: loads tokenizer
01_tokenize.py - Inspect embeddings → Pretrained GPT-2: loads model
02_embeddings.py - Inspect attention → Pretrained GPT-2: runs inference
03_attention.py - Score next token → Pretrained GPT-2: scores tokens
04_predict_next_token.py - Sample token loop → Pretrained GPT-2: runs inference
05_manual_generation_loop.py - Measure uncertainty → Pretrained GPT-2: scores and samples
07_why_it_hallucinates.py - Train and generate → Tiny Transformer: trains and samples
06_train_tiny_transformer_from_scratch.py - Learning experiments → Tiny language model: trains and evaluates
08_watch_it_learn.py - Tokenize text → Printed results: prints tokens
01_tokenize.py - Inspect embeddings → Printed results: prints comparisons
02_embeddings.py - Inspect attention → Printed results: prints weights
03_attention.py - Inspect attention → Attention heatmap: saves heatmap
03_attention.py - Score next token → Printed results: prints probabilities
04_predict_next_token.py - Sample token loop → Printed results: prints continuation
05_manual_generation_loop.py - Train and generate → Printed results: prints loss and text
06_train_tiny_transformer_from_scratch.py - Learning experiments → Printed results: prints accuracy
08_watch_it_learn.py - Measure uncertainty → Printed results: prints uncertainty
07_why_it_hallucinates.py