Git, environments, and the one-page ML mental model

Reproducible envs with uv, a Git workflow that survives real teams, and enough ML vocabulary to talk to research.

🐍 Module 0 7 min read Not started

Why this matters

You can be a brilliant agent designer and still get filtered at "do you actually know Git?" This lesson covers the workflow you will use every single day, plus the absolute minimum ML mental model you need to reason about LLMs without faking it in interviews.

Learning objectives

  1. Run a Git workflow that mirrors how AI startups actually work.
  2. Set up reproducible Python environments with uv (or conda if forced).
  3. Understand tokens, transformers, embeddings, and context windows well enough to defend choices.
  4. Pick a model size and provider for a given task without overthinking.

1. Git workflow for AI projects

Day-1 commands (memorize, do not look up)

powershell
git init
git add .
git commit -m "init: project skeleton"

git checkout -b feature/add-rag
# ... edit files ...
git add src/rag.py tests/test_rag.py
git commit -m "feat(rag): hybrid search with bm25 + cohere rerank"

git push -u origin feature/add-rag
# Open a PR on GitHub, get review, squash-merge

Branching pattern that hiring managers expect

  • main (or master) β€” always deployable.
  • feature/<short-name> β€” one feature, short-lived.
  • fix/<short-name> β€” bug fixes.
  • chore/<short-name> β€” refactors, deps.

One feature = one PR. Big PRs are reviewed badly and merged late.

Commit message format (Conventional Commits)

<type>(<scope>): <subject>

Examples that signal seniority:

  • feat(agent): add reflexion loop with critic node
  • fix(rag): chunk overlap was 0, fixed at 50
  • chore(deps): bump langgraph to 1.1.4
  • docs(readme): add deployment quickstart
  • test(eval): add 20 hallucination cases

.gitignore for AI projects (copy this)

.env
.venv/
__pycache__/
*.pyc
.pytest_cache/
.mypy_cache/
.ruff_cache/
.DS_Store
*.egg-info/
dist/
build/
node_modules/
*.duckdb
chroma_db/
faiss_index/
.langgraph_api/
.deepeval_cache/
*.ipynb_checkpoints

You never commit:

  • API keys (use .env)
  • Large model weights (use HuggingFace Hub)
  • Vector indexes (rebuild from data)
  • Cached LLM responses (could leak data)

2. Environment management β€” pick uv

In 2026, uv from Astral is the consensus choice. It is rust-fast, reproducible, and replaces pip, pip-tools, pyenv, virtualenv, and pipx in one tool.

powershell
# Install (Windows)
winget install astral-sh.uv

# New project
uv init agent-app
cd agent-app

# Add packages
uv add openai anthropic langchain langgraph chromadb pydantic instructor python-dotenv

# Add dev-only packages
uv add --dev pytest ruff mypy

# Run any command in the env
uv run python main.py
uv run pytest

# Lock + install on a new machine
uv sync

Why uv over conda/pip:

  • Lockfile (uv.lock) makes builds reproducible.
  • 10-100x faster.
  • Single tool instead of four.
  • One pyproject.toml for everything.

If your team forces conda, you still use it the same way: conda env create -f env.yml. The principles are identical.


3. The 1-page ML mental model

You do not need to derive backprop in interviews. You need a clean, accurate mental model of how LLMs work. Here it is.

Tokens

Every LLM speaks tokens, not words. A token is roughly 3-4 characters or 0.75 words in English. "agentic" is one token. "agentically" is two. Numbers and code split weirdly.

python
import tiktoken
enc = tiktoken.encoding_for_model("gpt-4.1")
print(len(enc.encode("Hello, world!")))   # 4 tokens
print(len(enc.encode("agentically")))      # 2 tokens

Why you care:

  • You pay per token in and out.
  • The context window (total input+output budget) is measured in tokens.
  • You can compress long prompts using token-aware tricks.

The Transformer (in 60 seconds)

A transformer is a neural network that reads a sequence of tokens and predicts the next token. It does this by:

  1. Turning each token into a vector (an embedding).
  2. Letting each token "attend" to relevant earlier tokens via the attention mechanism.
  3. Outputting a probability distribution over the next token.
  4. Sampling one and appending it.

That is it. Repeat 1000 times β†’ an essay.

The reason GPT-4.1 is smarter than GPT-3.5 is mostly scale: more parameters, more training data, more compute, plus reinforcement learning fine-tuning to follow instructions.

Context window

The maximum number of tokens (input + output) the model can consider in one call.

Model (mid-2026)Context window
GPT-4.11M tokens
GPT-4.1-mini1M tokens
Claude Opus 4.7200k tokens (1M beta)
Claude Sonnet 4.6200k tokens
Claude Haiku 4.5200k tokens
Gemini 2.5 Pro2M tokens
Llama 3.3 70B128k tokens
DeepSeek-V3128k tokens

Going over = truncation, error, or silent quality drop. You will use chunking and RAG to avoid needing to stuff everything in context.

Embeddings

An embedding is a vector (e.g. 1536 floats for text-embedding-3-small) that represents the meaning of a piece of text. Two texts about dogs sit close together; "dogs" and "stocks" are far apart.

You will use embeddings to:

  • Search documents semantically (RAG).
  • Cluster similar messages.
  • Detect drift in production data.
  • Recall similar past conversations (memory).

Three knobs you adjust most

KnobEffectDefault for agents
temperature (0-2)Randomness0.0 - 0.3
max_tokensOutput capCost control
top_p (0-1)Sample from smallest set summing to pleave at 1

Rule: for agents (decisions, tool calls), low temperature. For creative writing, high.

Two things models cannot do (be honest with yourself)

  1. Reliable arithmetic past 3-4 digits. Use a calculator tool.
  2. Know things after their knowledge cutoff. Use search or RAG.

4. Picking a model β€” the cheat sheet

TaskDefault pick (2026)Why
Cheap routing/classificationgpt-4.1-mini or claude-haiku-4.5Fast, cheap
Complex reasoningclaude-opus-4.7, gpt-5.5Best on hard tasks
Coding agentclaude-sonnet-4.6, gpt-5.5-codexSWE-bench leaders
RAG synthesisgpt-4.1-mini, claude-sonnet-4.6Long-context handling
Vision / chartsgpt-4o, claude-sonnet-4.6, gemini-2.5-proMultimodal
Cost-sensitive batchgemini-2.5-flash, open-source via GroqLowest cost/token
On-prem / privateLlama 3.3 70B, Qwen 2.5 72B, DeepSeek-V3Self-hosted

Always start with a smaller model. Upgrade only when you have evals showing it is needed.


Hands-on lab (60 minutes)

  1. Create a new GitHub repo agentic-foundations.
  2. Initialise with uv init.
  3. Add a tokens.py script that:
    • Loads three Wikipedia pages (use requests or httpx).
    • Counts tokens using tiktoken for gpt-4.1.
    • Prints token count and estimated cost at $0.40/1M input tokens.
  4. Add a pytest test that asserts each page has > 1000 tokens.
  5. Make 3 commits: chore: init, feat(tokens): add counter, test: add token tests.
  6. Push to GitHub.

You should end up with 3 commits, a passing test, and a clean repo.


Common pitfalls

  1. Committing .env β€” happens once, you lose your free credits. Add .env to .gitignore before the first commit.
  2. Pinning to latest β€” agent libs change weekly. Lock with uv.lock.
  3. Mixing conda + pip in the same env β€” chaos. Pick one tool, stick to it.
  4. Estimating cost in the UI β€” use tiktoken to know in code.
  5. Reading the same Wikipedia page in tests β€” flaky. Save fixtures to tests/fixtures/.

Self-check

  1. What does the attention mechanism do, in one sentence?
  2. Why is "agentically" 2 tokens but "agentic" is 1?
  3. Why does temperature=0 still sometimes produce different outputs?
  4. When would you pick Gemini 2.5 Pro over GPT-4.1?
  5. What is the danger of committing your chroma_db/ folder?

References

Sign in to save your progress and earn badges.