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.
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
- Run a Git workflow that mirrors how AI startups actually work.
- Set up reproducible Python environments with
uv(orcondaif forced). - Understand tokens, transformers, embeddings, and context windows well enough to defend choices.
- 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)
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-mergeBranching pattern that hiring managers expect
main(ormaster) β 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 nodefix(rag): chunk overlap was 0, fixed at 50chore(deps): bump langgraph to 1.1.4docs(readme): add deployment quickstarttest(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_checkpointsYou 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.
# 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 syncWhy uv over conda/pip:
- Lockfile (
uv.lock) makes builds reproducible. - 10-100x faster.
- Single tool instead of four.
- One
pyproject.tomlfor 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.
import tiktoken
enc = tiktoken.encoding_for_model("gpt-4.1")
print(len(enc.encode("Hello, world!"))) # 4 tokens
print(len(enc.encode("agentically"))) # 2 tokensWhy 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:
- Turning each token into a vector (an embedding).
- Letting each token "attend" to relevant earlier tokens via the attention mechanism.
- Outputting a probability distribution over the next token.
- 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.1 | 1M tokens |
| GPT-4.1-mini | 1M tokens |
| Claude Opus 4.7 | 200k tokens (1M beta) |
| Claude Sonnet 4.6 | 200k tokens |
| Claude Haiku 4.5 | 200k tokens |
| Gemini 2.5 Pro | 2M tokens |
| Llama 3.3 70B | 128k tokens |
| DeepSeek-V3 | 128k 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
| Knob | Effect | Default for agents |
|---|---|---|
temperature (0-2) | Randomness | 0.0 - 0.3 |
max_tokens | Output cap | Cost control |
top_p (0-1) | Sample from smallest set summing to p | leave at 1 |
Rule: for agents (decisions, tool calls), low temperature. For creative writing, high.
Two things models cannot do (be honest with yourself)
- Reliable arithmetic past 3-4 digits. Use a calculator tool.
- Know things after their knowledge cutoff. Use search or RAG.
4. Picking a model β the cheat sheet
| Task | Default pick (2026) | Why |
|---|---|---|
| Cheap routing/classification | gpt-4.1-mini or claude-haiku-4.5 | Fast, cheap |
| Complex reasoning | claude-opus-4.7, gpt-5.5 | Best on hard tasks |
| Coding agent | claude-sonnet-4.6, gpt-5.5-codex | SWE-bench leaders |
| RAG synthesis | gpt-4.1-mini, claude-sonnet-4.6 | Long-context handling |
| Vision / charts | gpt-4o, claude-sonnet-4.6, gemini-2.5-pro | Multimodal |
| Cost-sensitive batch | gemini-2.5-flash, open-source via Groq | Lowest cost/token |
| On-prem / private | Llama 3.3 70B, Qwen 2.5 72B, DeepSeek-V3 | Self-hosted |
Always start with a smaller model. Upgrade only when you have evals showing it is needed.
Hands-on lab (60 minutes)
- Create a new GitHub repo
agentic-foundations. - Initialise with
uv init. - Add a
tokens.pyscript that:- Loads three Wikipedia pages (use
requestsorhttpx). - Counts tokens using
tiktokenforgpt-4.1. - Prints token count and estimated cost at $0.40/1M input tokens.
- Loads three Wikipedia pages (use
- Add a
pytesttest that asserts each page has > 1000 tokens. - Make 3 commits:
chore: init,feat(tokens): add counter,test: add token tests. - Push to GitHub.
You should end up with 3 commits, a passing test, and a clean repo.
Common pitfalls
- Committing
.envβ happens once, you lose your free credits. Add.envto.gitignorebefore the first commit. - Pinning to
latestβ agent libs change weekly. Lock withuv.lock. - Mixing conda + pip in the same env β chaos. Pick one tool, stick to it.
- Estimating cost in the UI β use
tiktokento know in code. - Reading the same Wikipedia page in tests β flaky. Save fixtures to
tests/fixtures/.
Self-check
- What does the attention mechanism do, in one sentence?
- Why is "agentically" 2 tokens but "agentic" is 1?
- Why does temperature=0 still sometimes produce different outputs?
- When would you pick Gemini 2.5 Pro over GPT-4.1?
- What is the danger of committing your
chroma_db/folder?
References
Sign in to save your progress and earn badges.