Notebooks are the preferred environment for exploration, prototyping, and learning. They let you run code cell by cell, inspect intermediate results, and mix code with documentation. Nearly every LLM tutorial and research artifact is published as a notebook. Code Fragment C.3.1 below puts this into practice.
Local Jupyter Setup
This snippet shows how to install and launch Jupyter for local notebook development.
# Install Jupyter in your virtual environment
pip install jupyterlab
# Launch the notebook server
jupyter lab
# Or use the classic interface
jupyter notebook
Google Colab Tips
- Free GPU access: Go to Runtime > Change runtime type > select T4 GPU. The free tier gives you a T4 with 15 GB VRAM, enough to run 7B parameter models in 4-bit quantization.
- Mounting Google Drive: Use
from google.colab import drive; drive.mount('/content/drive')to access your files and save checkpoints persistently. - Installing packages: Use
!pip install transformers peft trlat the top of your notebook. The exclamation mark runs shell commands from within a notebook cell. - Secrets management: Use Colab's Secrets panel (the key icon in the left sidebar) to store API keys instead of hardcoding them in cells.
- Session limits: Free Colab sessions disconnect after idle periods and have usage quotas. Save checkpoints frequently to Google Drive.
Notebooks allow out-of-order cell execution, which can lead to hidden state bugs: a variable defined in cell 10 might be used in cell 3 after you reorder things. Before sharing a notebook, always restart the kernel and run all cells sequentially to verify that the notebook works from a clean state. For production code, always refactor notebooks into proper Python modules.