Skip to content

About

Hands-on beginner exploration of Google Colab, Python, and LangChain fundamentals with HuggingFace, OpenAI, and tokenization notebooks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google_colab101

A personal learning repository for exploring Google Colab, Python, and LangChain fundamentals.

This repository documents a hands-on beginner exploration of the Google Colab environment and the LangChain framework. It is a learning and experimentation space — not a production project or course.


Who This Is For

  • Anyone beginning to explore Google Colab as a Python learning environment
  • Learners who want a simple first look at LangChain concepts before diving into deeper tutorials
  • Educators looking for lightweight starting-point notebooks to demonstrate Colab and LangChain basics

Learning Objectives

By working through these notebooks, you can expect to:

  • Understand what Google Colab is and why it is useful for learning Python and AI libraries
  • Write and execute basic Python code in a Colab notebook environment
  • Install packages using pip directly inside Colab cells
  • Understand the core LangChain concepts: LLMs, Prompt Templates, Chains, Agents, and Memory
  • Use langchain-huggingface and langchain-openai integrations as LLM providers
  • Understand how tokenization works in transformer-based language models (using a BERT tokenizer via transformers)
  • Handle API keys and secrets safely in a Colab environment

Repository Structure

google_colab101/
├── colab101.ipynb                     # Root: Colab orientation + LangChain introduction
├── chapter1/
│   └── tokenization.ipynb             # LLM tokenization fundamentals
├── Langchain Tutorial/
│   └── 00_langchain_intro.ipynb       # Structured LangChain intro (HF + OpenAI integrations)
├── README.md
└── LICENSE                            # MIT License — Copyright (c) 2025 HITESH PATEL

Notebook Index

colab101.ipynb — Colab Orientation & LangChain First Look

Location: /colab101.ipynb
Open in Colab: Open In Colab

What it covers (confirmed from inspected cells and recorded outputs):

Section Content
What is Google Colab? Overview of Colab features: cloud-based notebooks, free GPU/TPU access, no local setup required
Basic Python in Colab Writing and running code cells; print statements; variable assignment
Installing LangChain !pip install langchain — demonstrates in-notebook package installation
LangChain Basics Explanation of core concepts: LLMs, Chains, Agents; code example using ChatPromptTemplate, StrOutputParser, and Ollama from langchain_community

Dependencies installed in this notebook:

  • langchain (recorded as 0.3.27 in cell outputs)
  • langchain-core, langchain-community, langchain-text-splitters, langsmith (pulled automatically as dependencies)

⚠️ Ollama note: The LangChain basics section contains a code example that imports Ollama from langchain_community. Ollama requires a separately running local server — this cell will not execute successfully in standard Colab unless you have an accessible Ollama endpoint configured. The cell is illustrative only. No OpenAI or Hugging Face API key is required for this notebook.


chapter1/tokenization.ipynb — LLM Tokenization

Location: /chapter1/tokenization.ipynb

What it covers (confirmed from inspected cells and recorded outputs):

Working with a BERT-style tokenizer from the transformers library to understand how language models break text into tokens.

The notebook demonstrates:

  • Tokenizing an example sentence using a BERT tokenizer
  • Viewing the resulting token IDs (integer representations)
  • Counting the number of tokens in an input sequence
  • Decoding token IDs back to human-readable token strings

Sample output recorded in notebook:

[CLS] this token is used to separate different segments in the input. for tasks like
question answering or natural language inference, where two sentences are input [SEP]

Token IDs: [101, 2023, 19204, 2003, ... 102]
COUNT NUMBER OF TOKENS : 29
Decoded: [CLS], this, token, is, used, to, separate, different, segments, in,
         the, input, ., for, tasks, like, question, answering, or, natural,
         language, inference, ,, where, two, sentences, are, input, [SEP]

Dependencies required:

  • transformers (Hugging Face) — pre-installed in Colab's default runtime

Note: No API key is required. Internet access is needed on first run to download the tokenizer weights from Hugging Face Hub.


Langchain Tutorial/00_langchain_intro.ipynb — Structured LangChain Introduction

Location: /Langchain Tutorial/00_langchain_intro.ipynb
Open in Colab: Open In Colab

What it covers:

A structured introduction to LangChain, adapted from the Pinecone LangChain Handbook.

Topic Detail Confirmed?
LangChain framework overview Prompt templates, LLMs, Tool/function calling, Agents, Memory ✅ Confirmed in inspected cells
Hugging Face LLM integration Using langchain-huggingface with a Hugging Face Inference token ✅ Confirmed in inspected cells
HF API token setup Generating a fine-grained HF token; safe loading via os.getenv('HF_TOKEN') with getpass fallback ✅ Confirmed in inspected cells
OpenAI LLM integration Listed as a provider; langchain-openai==0.3.22 is pinned in the install cell ⚠️ Inferred — cells beyond the HF section were not fully visible during inspection

Dependencies pinned in this notebook:

langchain==0.3.25
langchain-huggingface==0.3.0
langchain-openai==0.3.22

⚠️ API key required: This notebook requires a Hugging Face API token (HF_TOKEN) to use Hugging Face Inference endpoints. See Handling API Keys Safely below for setup instructions. Do not hardcode your API key in the notebook.


Prerequisites

No local installation is required. All notebooks are designed to run in Google Colab.

You will need:

  • A Google account to access Google Colab
  • A Hugging Face account and API token (for 00_langchain_intro.ipynb only)
  • Basic familiarity with Python is helpful but not required for colab101.ipynb

How to Run

Option 1 — Open directly in Colab (recommended)

Click the Open in Colab badge in any notebook section above, or construct the URL manually using this pattern:

https://colab.research.google.com/github/contact2hitech/google_colab101/blob/master/<path-to-notebook>

For notebooks inside the Langchain Tutorial/ folder, encode the space as %20:

https://colab.research.google.com/github/contact2hitech/google_colab101/blob/master/Langchain%20Tutorial/00_langchain_intro.ipynb

Option 2 — Clone and run locally

git clone https://github.com/contact2hitech/google_colab101.git
cd google_colab101
# Open .ipynb files in VS Code, JupyterLab, or any Jupyter-compatible environment

Handling API Keys Safely

For Langchain Tutorial/00_langchain_intro.ipynb, which requires HF_TOKEN:

Recommended approach — Colab Secrets:

  1. Open the notebook in Colab
  2. Go to Runtime → Manage secrets
  3. Add a secret named HF_TOKEN with your Hugging Face token as the value
  4. The notebook will read it automatically via os.getenv('HF_TOKEN'); a getpass prompt serves as a fallback if the secret is not set

Never:

  • Paste your API key directly into a notebook cell
  • Commit a notebook that has a real API key visible in its source or output cells
  • Share your token publicly

Scope: colab101.ipynb and tokenization.ipynb require no API keys.


Technologies

Python packages used across notebooks:

Package Purpose Notebook
langchain Core LangChain framework colab101.ipynb
langchain-core Prompt templates, output parsers, runnables colab101.ipynb
langchain-community Community LLM integrations (Ollama) colab101.ipynb
langchain-huggingface Hugging Face LLM integration 00_langchain_intro.ipynb
langchain-openai OpenAI LLM integration 00_langchain_intro.ipynb
langsmith LangChain tracing and observability (auto-dependency) colab101.ipynb
transformers Hugging Face tokenizers and models tokenization.ipynb
pydantic Data validation (auto-dependency of langchain) colab101.ipynb

Platform: Google Colab — recorded outputs were produced on Python 3.12. The Python version available in Colab at the time you run these notebooks may differ.


Suggested GitHub Topics

python · langchain · google-colab · llm · ai · jupyter-notebook · transformers · huggingface · beginners · learning


License

MIT — Copyright (c) 2025 HITESH PATEL. Free to use, adapt, and share with attribution.


Personal learning repository — Hitesh Patel · Hi-Tech AI Solutions & Services

About

Hands-on beginner exploration of Google Colab, Python, and LangChain fundamentals with HuggingFace, OpenAI, and tokenization notebooks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages