# Practice Labs: SLP (Jurafsky/Martin)

**Source PDF:** [ed3book_jan26.pdf](ed3book_jan26.pdf)
**Book:** *Speech and Language Processing* (3rd Edition draft) by Daniel Jurafsky & James H. Martin

This book is a comprehensive NLP textbook covering tokenization, language models, embeddings, neural networks, transformers, and LLMs. Labs follow the book's chapter order.

Use this folder as a compact NLP foundations bridge inside the math section. It is especially useful if you want the conceptual path from tokens and n-grams to transformers and LLMs in one place.

## Labs

| Lab | Topic | Book Chapter(s) | Key Concepts |
|-----|-------|-----------------|-------------|
| [Lab 01](lab_01_words_tokens.ipynb) | Words, Tokens & Text Processing | Ch 2: Words and Tokens | BPE tokenization, regex, edit distance |
| [Lab 02](lab_02_ngram_language_models.ipynb) | N-gram Language Models | Ch 3: N-gram Language Models | N-grams, perplexity, smoothing, text generation |
| [Lab 03](lab_03_word_embeddings.ipynb) | Word Embeddings | Ch 5: Embeddings | Co-occurrence, TF-IDF, Word2Vec, cosine similarity |
| [Lab 04](lab_04_neural_networks.ipynb) | Neural Networks from Scratch | Ch 6: Neural Networks | XOR, feedforward nets, backprop, optimizers |
| [Lab 05](lab_05_transformers_attention.ipynb) | Transformers & Attention | Ch 8: Transformers | Self-attention, multi-head, positional encoding |
| [Lab 06](lab_06_large_language_models.ipynb) | Large Language Models | Ch 7, 9, 10: LLMs, MLMs, Post-training | Sampling, prompting, BERT masking, RLHF |

## How to Use

1. Each lab is a Jupyter notebook with theory (markdown) and fully implemented code cells
2. Read the theory cells, study the implementations, and run each cell
3. Open in Jupyter: `jupyter notebook lab_01_words_tokens.ipynb`

## Prerequisites

- Python 3.8+
- NumPy
- Matplotlib

## Suggested Order

Follow the labs in order (1 through 6) as they build upon each other:
1. **Lab 01** - Text processing fundamentals
2. **Lab 02** - Statistical language models
3. **Lab 03** - Word representations
4. **Lab 04** - Neural network foundations
5. **Lab 05** - Transformer architecture
6. **Lab 06** - Modern LLMs and applications

## How To Use This Folder Well

- Follow the order because each lab builds on the previous one.
- Use these labs to connect NLP concepts to implementation rather than treating them as only theory notes.
- Pair this folder with the token, embeddings, and prompt-engineering phases when you want the broader curriculum context.

## What Comes Next

- Continue to [../../04-token/README.md](../../04-token/README.md) and [../../05-embeddings/README.md](../../05-embeddings/README.md) for the main repo path.
- Continue to [../../08-rag/README.md](../../08-rag/README.md) if you want to apply language-model retrieval systems.
- Continue to [../../12-llm-finetuning/README.md](../../12-llm-finetuning/README.md) if your interest shifts toward adapting models.
