Cheat sheet · Specialise
RAG cheat sheet
Opens with creditsA quick-revision book on retrieval augmented generation: how documents become chunks and vectors, how to retrieve and rerank the right ones, how to prompt for grounded answers and how to measure and fix a pipeline that gets things wrong. Vector stores, LangChain and raw LLM API calls have their own sheets; this one is about the pipeline.
Chapters
8 chapters · 54 concepts
1RAG basicsWhat retrieval augmented generation is, the two halves of every pipeline and when it is the right tool.6 concepts
- 1Retrieval augmented generationA pattern where your code first searches your own documents for passages relevant to a question, then gives those passages to an LLM to answer from.
- 2Indexing and query pipelinesIndexing runs ahead of time: load, clean, chunk, embed and store documents.
- 3RAG vs fine-tuningRAG adds knowledge at question time; fine-tuning changes model weights to learn a style, format or narrow skill.
- 4RAG vs long contextIf all your content fits comfortably in the model context window, you can sometimes paste it in instead of retrieving.
- 5Start with a naive baselineFixed-size chunks, one embedding model, top 5 by vector similarity and a simple grounded prompt.
- 6Knowledge baseThe collection of documents the system can retrieve from: docs, tickets, PDFs, wiki pages or database rows.
6 in this chapterOpen this chapter2Loading and chunkingTurning messy documents into clean, well-sized chunks with the metadata you will need later for filters and citations.8 concepts
- 1Document parsingExtracting clean text from PDFs, HTML, slides and docs while keeping structure such as headings, tables and lists.
- 2ChunkingSplitting documents into passages small enough to embed and retrieve precisely, but large enough to make sense alone.
- 3Fixed-size chunks with overlapCutting text every N tokens or characters, with each chunk repeating the last part of the previous one.
- 4Structure-aware chunkingSplitting on natural boundaries first, such as headings, then paragraphs, then sentences, and only cutting mid-sentence as a last resort.
- 5Semantic chunkingPlacing chunk boundaries where the meaning shifts, detected by comparing embeddings of neighbouring sentences.
- 6Choosing chunk sizeSmall chunks match questions precisely but lose surrounding context; large chunks keep context but dilute the embedding and waste prompt space.
- 7Chunk metadataFields stored with each chunk such as source URL, title, section heading, date, language, product version and access group.
- 8Small-to-big retrievalEmbed small chunks for precise matching, but hand the model the larger parent section they came from.
8 in this chapterOpen this chapter- Embeddings and the indexTurning chunks into vectors and storing them. The Vector databases cheat sheet covers index types and stores in depth; this is what RAG needs from them.6 conceptsOpens with credits
- RetrievalFinding the right chunks: top k, keyword search, hybrid search, filters and rewriting the question before searching.8 conceptsOpens with credits
- Reranking and context buildingChoosing the best few chunks from the candidates and assembling them into a context the model can use.6 conceptsOpens with credits
- Grounded generationPrompting the model to answer only from the retrieved text, cite it and admit when the answer is not there.6 conceptsOpens with credits
- Evaluating RAGMeasuring retrieval and generation separately, so you know which half to fix.7 conceptsOpens with credits
- Failure modes and advanced patternsWhy RAG answers go wrong in production, and the patterns people reach for once the basics work.7 conceptsOpens with credits
- 9Glossary, A to ZEvery concept in the sheet and the smaller terms it uses, in one list.61 terms
About this sheet
Retrieval augmented generation end to end: chunking, embeddings, hybrid retrieval, reranking, grounded prompts, evaluation and failure modes.
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.
Cheat sheets
See all- AI agents and MCP cheat sheetTool calling, MCP servers, evals.
- GenAI app architecture cheat sheetHow a production GenAI app fits together: request flow, layers, RAG, agent loop, memory, caching, guards, evals, tracing, folder layout and launch checklist.
- Coding with AI tools cheat sheetClaude Code, Cursor, Copilot, used well.
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