Cheat sheet · Specialise
AI engineering cheat sheet (Python)
Opens with creditsA quick-revision companion to the AI engineering roadmap in its Python edition: how LLMs work, prompting, RAG, evals, tool calling, MCP, agents and production, with snippets using the official SDKs, Pydantic and NumPy. Skim a chapter before a project or a technical conversation.
Chapters
9 chapters · 70 concepts
1How LLMs work: tokens and contextWhat a model does when it answers: text becomes tokens, the model predicts one token at a time inside a fixed context window, and every token costs money and time.9 concepts
- 1Large language modelA neural network, almost always a transformer, trained on huge amounts of text to predict the next token.
- 2Tokens and tokenisationModels read and write tokens: chunks of text from a fixed vocabulary, often word pieces.
- 3The context windowThe maximum number of tokens a model handles in one request, counting the system prompt, history, tool definitions, retrieved documents and the output.
- 4Token pricingProviders charge per million input tokens and per million output tokens, with output several times more expensive.
- 5Rate limitsCaps on requests per minute and on input and output tokens per minute for an account or workspace.
- 6Temperature and samplingThe model outputs a probability for every possible next token and sampling picks one.
- 7HallucinationA fluent, confident answer that is false or unsupported, such as an invented citation, API, number or policy.
- 8Reasoning models and effortModels that generate internal reasoning tokens before the final answer.
- 9Choosing a modelPicking a model by measuring quality on your own eval set against cost and latency.
9 in this chapterOpen this chapter2Prompting and model APIsCalling a model well: the request shape, system prompts, clear instructions and examples, streaming, handling failures and treating prompts as code.9 concepts
- 1Chat messages APIThe core request: a model id, a maximum output length, an optional system prompt and a list of user and assistant messages.
- 2System promptInstructions sent separately from the conversation that set the role, rules, tone, output format and background for every turn.
- 3Clear, specific instructionsStating the task, audience, constraints, what good output looks like and the exact format, as you would brief a capable colleague with no context.
- 4Few-shot examplesIncluding a handful of worked input and output examples in the prompt so the model copies their format, style and judgement.
- 5Streaming responsesReceiving output piece by piece as it is generated, over server-sent events, instead of waiting for the whole response.
- 6Timeouts, retries and backoffSetting a timeout on every call and retrying transient failures (429, 5xx, overloaded, dropped connections) with exponential backoff and jitter.
- 7Hosted vs local modelsHosted models run behind a provider API.
- 8Prompts in version controlTreating prompts as code: stored in the repository or a prompt registry, reviewed, versioned and linked to the eval results each version produced.
- 9Open-weight modelsModels whose trained weights are published for download, each under its own licence.
9 in this chapterOpen this chapter- RAG: embeddings, chunking and retrievalGiving a model your own knowledge: embed and chunk documents, retrieve the best passages with vector and keyword search, then answer only from them with citations.11 conceptsOpens with credits
- Evals: measure before you add moreHow you know a change helped: read real outputs, build a small labelled test set, check with code first, use a judge model only once it agrees with you, and run it all in CI.8 conceptsOpens with credits
- Tool calling and structured outputLetting a model act and return data your code can trust: tool definitions, the tool calling loop, schemas, validation and errors the model can recover from.7 conceptsOpens with credits
- MCP: Model Context ProtocolThe open standard for plugging tools and data into AI applications: who talks to whom, what a server exposes, how it connects and how to build one.5 conceptsOpens with credits
- Agents and durable executionWhen to let the model drive, and how to keep it safe and affordable: the agent loop, context engineering, hard limits, checkpoints, human approval and multiple agents.7 conceptsOpens with credits
- Running AI systems in productionWhat it takes to run an LLM feature for real users: tracing, guardrails and injection defence, caching, routing and fallbacks, latency and cost budgets, and when to fine-tune or self-host.10 conceptsOpens with credits
- Put it together: ship a production GenAI appHow the parts of a real GenAI app fit together, where each lives in the repo, and what must be true before launch. The GenAI app architecture cheat sheet goes deeper.4 conceptsOpens with credits
- 10Glossary, A to ZEvery concept in the sheet and the smaller terms it uses, in one list.184 terms
About this sheet
Build products on LLMs and generative AI.
Related on Sefism
Picked from the other libraries by shared topics.
Roadmaps
See allBest practices
See all- Best Practices for Building LLM AppsHow to build LLM apps and agents that hold up in production: prompts, evals, prompt injection, tool permissions, cost, logging and privacy.
- Prompt Engineering Best PracticesHow to write prompts that work the same way on the hundredth input as on the first: clear instructions, structure, examples, reasoning, output control and testing.
- Best Practices for AI Coding AssistantsHow to get reliable code from AI coding assistants and agents: instruction files, task prompts, verification, review, security, dependencies and session hygiene.
Checklists
See all- RAG Production ChecklistA RAG production checklist: chunking, embeddings, hybrid search, reranking, per-user permissions, citations, evals, re-indexing and cost, with how to verify each check.
- LLM Evaluation ChecklistAn LLM evaluation checklist: success criteria, eval datasets, code and model graders, judge calibration, agent evals, safety tests and production monitoring, with how to verify each check.
- AI Feature Launch ChecklistAn AI feature launch checklist: use case fit, evals, UX for errors, disclosure, human override, abuse filters, rate limits, cost caps, prompt privacy, monitoring and rollback.
Project structures
See all- GenAI RAG app (FastAPI) project structureFor developers turning a "chat with your documents" demo into an app people can rely on. A FastAPI backend where every layer has a home: ingestion workers, retrieval, prompts as versioned files, model clients with fallbacks and cost caps, guards, evals that gate CI, and tracing, so a wrong answer can be traced to the step that caused it.
- AI agent with an MCP server project structureFor developers who want to give AI assistants safe access to their own data or API. A TypeScript MCP server built on the official SDK, organised by feature (tasks, projects) with each feature owning its tools, resources and prompts, served over stdio for local hosts and Streamable HTTP with OAuth for remote ones, plus a small agent and the evals that prove a model can use it.
- Machine learning project project structureFor students and analysts whose model works in a notebook and now needs to be reproducible, reviewable, served and watched. It starts from the Cookiecutter Data Science v2 layout (immutable raw data, numbered notebooks, a real Python package) and grows into versioned data with DVC, typed parameters, data validation with pandera, experiment tracking and a model registry with MLflow, a FastAPI prediction service, drift monitoring and, for a team, scheduled retraining, model cards, fairness checks and shadow deployment.
Career questions
See all- Which AI tools do employers expect junior developers to know in 2026?Employers rarely require a specific brand. They expect you to use an AI coding assistant well (in the editor and in the terminal), to review and test what it produces, to call an LLM API in a small feature, and to explain when you would not use AI. Pick one assistant, learn it properly, and show judgement in your projects.
- How do I use AI to become a better engineer instead of becoming dependent on it?Decide the job AI does before you open it. Use it as a tutor, reviewer and sparring partner that explains and challenges, not a vending machine that hands you finished code. Attempt first, ask second, and always be able to explain and defend what you ship.
- How do I start learning AI agents as a software engineer?Start with one LLM API and plain code: a loop that calls the model, lets it pick a tool, runs the tool and feeds the result back. Build one small agent that does a real task end to end, add evaluation and guardrails, and only then reach for a framework. Agents are software engineering first.
Work with me
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
- 1:1 Mentorship
- Fresh Graduate Mentorship
- Career Guidance
Brand deals, promos and partnerships: tauseeffayyaz@gmail.com