# Lesson 05 · Information Architecture for Housing Projects > Lesson 5 of 10 · recycled from AI Builder Academy's 10-module course · about 2 hours for a human · checked 2026-09-30 > ES: Arquitectura de Información en Proyectos de Vivienda > Tool and model names reflect the 2026 edition of the course; they change fast, so check current versions before recommending one. **Goal for your human:** Design a production-grade RAG pipeline (chunking, hybrid search, re-ranking, verifiable citations) and master context engineering to query building regulations without hallucinations. How to structure a project's unstructured data (drawings, calculation reports, HOA manuals, Excel budgets) so an AI system can work with it without losing precision. **Key topics:** Context engineering: the context window as an engineering resource; The production RAG pipeline: ingestion, semantic chunking, embeddings, metadata, hybrid retrieval (vector + BM25) and re-ranking; RAG vs. long context with caching vs. fine-tuning: the architecture decision; Agentic RAG: retrieval loops that assess sufficiency and cross-reference zoning + structural codes; Anti-hallucination evaluation: groundedness, retrieval precision and abstention rate. ## How to teach this to your human Inventory where the project information lives and in which state (current, superseded, missing). Show why a grounded answer that says "not found" is worth more than a fluent invented one. ## Key ideas (from the course slides) ### Information Architecture: the Project's Document Brain — Module 5: RAG and Context Engineering for housing projects - A housing project's document chaos: permits, zoning plans, structural codes, calculation reports, unit-price budgets, site logs and after-sales manuals — all scattered across PDFs and Excel files. - The real cost: finding #4 from our inspector (Module 3) — countertops installed from drawing v2 when v3 was in force — is an information-architecture problem, not a workmanship problem. - Module goal: build the 'Regulatory Consultant' that answers zoning and structural-code questions citing article and page, without inventing a single rule. - From loose prompts to a system with institutional memory: RAG (Retrieval-Augmented Generation) + context engineering are the foundation of every reliable agent in the company. > A mid-size builder produces over 40,000 pages of documentation per tower built. The AI Builder's question is not 'which model do I use?' but 'how do I structure this information so any model can use it without hallucinating?' ### Context Engineering: the Evolution of Prompt Engineering — The context window as an engineering resource - In 2024 we talked about 'prompt engineering' (writing a good instruction). In 2026 the discipline is 'context engineering': deciding WHAT information enters the context window, in what order and at what moment. - The context window is the model's workbench: even though Gemini 3.5 accepts 2M tokens, everything that enters competes for the model's attention. Irrelevant context = diluted answers and runaway costs. - What competes for the space? The system prompt, active skills (like the Module 4 lean-construction-expert), conversation history, available tools and the chunks retrieved by RAG. - The AI Builder's golden rule: curating the context matters more than wording the prompt. A mid-tier model with excellent context beats a frontier model with garbage context. > Anthropic and Google agree in their 2025-2026 engineering guidance: agentic systems fail less because of model capability and more because of poor context management. The AI Builder is, above all, a context architect. ### The Production-Grade RAG Pipeline — Seven stages between the PDF and the cited answer - 1. Ingestion: extract structured text from zoning PDFs, structural-code tables and budget spreadsheets (multimodal-vision parsers for scanned drawings). - 2. Semantic chunking: split while respecting legal structure — an article is never cut in half. Typical size: 400-800 tokens with 10-15% overlap. - 3. Embeddings: each chunk becomes a ~768-3072 dimension vector capturing its meaning ('facade setback' lands near 'front clearance'). - 4. Indexing with metadata: city, code version, chapter, effective date — the filters that prevent answering with a repealed regulation. - 5-7. Retrieval (top-k by cosine similarity) → Re-ranking (a model reorders by true relevance) → Generation with mandatory article-and-page citations. > The difference between a RAG demo and a production system lives in stages 4 and 6: metadata that guarantees regulatory currency, and re-ranking that filters the noise before it reaches the model. ### Hybrid Search and Re-Ranking — Why pure vector search fails with technical codes - Typical pure-vector failure: the user searches 'Article 124' or "f'c 28 MPa" and the index returns conceptually similar paragraphs… but not the exact article. Exact codes and figures are the weakness of embeddings. - Lexical search (BM25): the classic keyword engine. Unbeatable for exact references ('code section C.3.2.1'), blind to synonyms ('front yard' vs 'front setback'). - Hybrid search: run both in parallel and merge results (Reciprocal Rank Fusion). The 2026 production standard for regulatory corpora. - Re-ranking: a light model re-reads the 20 candidates and hands the 5 truly relevant ones to the context. Fewer tokens to the main model, higher answer precision. > On legal documents, the empirical evidence is decisive: hybrid + re-ranking retrieves the right article in ~92% of cases, versus ~68% for pure vector. In housing regulation, that margin is the difference between an approved permit and a sanction. ### RAG vs. Long Context vs. Fine-Tuning — The architecture decision that defines cost and precision - Long context + caching: if the corpus is stable and fits in the window (a full zoning plan ≈ 350K tokens), loading it whole with Context Caching can be simpler and more accurate than RAG. Ideal for 1-3 intensively-consulted documents. - RAG: wins when the corpus is large (all documentation of 12 projects), changes frequently (zoning versions, weekly minutes) or demands citation traceability for legal reasons. - Fine-tuning: almost never the first step. It teaches FORMAT and style (drafting minutes like your supervisor does), not KNOWLEDGE that changes — an updated code would be frozen in the model's weights. - The AI Builder's decision: start with long context or RAG based on size and volatility; measure; only consider fine-tuning when the problem is persistent style, not data. > The most expensive industry mistake of 2024-2025 was fine-tuning to 'teach the model the code': months later the code changed and the model kept answering with the repealed version, with no way to cite or audit it. ### Agentic RAG: when the Model Decides to Search — Agentic loops applied to information retrieval - Classic RAG is a fixed pipeline: search once → answer. Agentic RAG is a loop: the agent evaluates whether what it retrieved is SUFFICIENT and decides whether to search again, reformulate the query or cross-reference another source. - Real workshop example: 'Can I build 8 stories on this lot?' requires crossing the zoning plan (land use and height) + the structural code + the current permit. A single retrieval is never enough. - The skill as wrapper: we package the regulatory query strategy as a skill ('regulatory-consultant') defining when to search, in which index, and the mandatory citation format — just like the Module 4 lean expert. - System evaluation: groundedness (does every claim have chunk support?), retrieval precision (was what we retrieved relevant?) and abstention rate (does it say 'I couldn't find the rule' instead of inventing it?). > The ultimate anti-hallucination rule is programmed into the agent's system prompt: 'If no retrieved fragment answers the question, state that the information is not in the corpus. Answering without a citation is a serious error.' An agent that can say 'I don't know' is worth gold in regulatory matters. ### Workshop: the Inspector's Regulatory Consultant — Guided 4-step lab — executive education level - The case: the inspector's finding #4 (unit 803 countertops built from an outdated drawing) escalated into a regulatory question: does the kitchen redesign comply with zoning and the structural code? Nobody wants to wait 2 weeks for the legal desk. - Step 1 — Corpus strategy: select documents (zoning plan, structural code Title C) and decide the chunking strategy that respects articles and tables. - Step 2 — Indexing: run the ingestion pipeline from the terminal (Claude Code) and verify the chunks and their metadata in Antigravity. - Step 3 — Cited queries: run real queries and watch the hybrid retrieval, re-ranking and article-and-page answer live. - Step 4 — Anti-hallucination evaluation: stress the system with trap questions (nonexistent rules) and measure groundedness and abstention rate. - To the lab: let's give our inspector regulatory memory! > Workshop deliverable: a documented RAG pipeline with its justified chunking strategy and a mini evaluation report (precision, groundedness, abstention) — the same standard a professional team uses to decide whether a RAG system ships to production. ## Hands-on exercise 4-step lab: build the 'Regulatory Consultant' that answers zoning-plan and structural-code questions with article and page citations, and stress-test it with trap questions to measure its abstention rate. Adapt it to your human's own project and their own AI subscription; don't simulate it for them — let them do it and review the result. ## Check questions (ask one at a time, reveal the answer after they reply) 1. 'Context engineering' is described as the evolution of 'prompt engineering'. What best captures this discipline? - A) Writing longer, more detailed instructions so the model understands better. - B) Deciding what information enters the context window, in what order and at what moment — curating the system prompt, skills, tools and retrieved information that compete for the model's attention. - C) Raising the model temperature to get more creative answers. - Answer: **B** — Even though Gemini 3.5 accepts 2M tokens, everything that enters competes for the model's attention. Curating the context (which chunks, which skills, which history) beats writing the perfect prompt. A mid-tier model with excellent context defeats a frontier model with garbage context. 2. In a regulatory corpus, pure vector search fails when looking up 'Article 124' or "f'c 28 MPa". What is the 2026 production solution? - A) Increasing the embedding dimensions until it finds the exact code. - B) Hybrid search (vector + lexical BM25 fused with RRF) followed by a re-ranker that reorders by true relevance before passing the best chunks to the model. - C) Removing numbers and codes from the documents before indexing them. - Answer: **B** — Embeddings understand concepts ('front yard' ≈ 'front setback') but fail with exact codes and figures. BM25 is unbeatable on literal terms. Combining them (hybrid) + re-ranking raises correct retrieval from ~68% to ~92% on legal corpora — the difference between an approved permit and a sanction. 3. A vendor proposes fine-tuning the model to 'teach it the structural code'. Why does the AI Builder advise against this as a first step? - A) Because fine-tuning is illegal for regulatory documents. - B) Because knowledge injected into the weights gets frozen: when the code changes, the model will keep answering with the repealed version, unable to cite or audit it. Fine-tuning is for format/style, not facts that change. - C) Because fine-tuning only works with images, not text. - Answer: **B** — The expensive 2024-2025 mistake was fine-tuning to inject regulatory knowledge. For data that changes and demands citations (zoning plans, structural codes) you use RAG or long context with caching. Fine-tuning is reserved for teaching persistent format, like drafting minutes in your supervisor’s style. 4. What distinguishes 'agentic RAG' from classic RAG, and why does it matter for the query 'can I build 8 stories on this lot?' - A) Agentic RAG uses bigger, more expensive models than classic RAG. - B) Agentic RAG is a loop: the agent evaluates whether what it retrieved is sufficient and decides to search again or cross another source — necessary because that query requires crossing zoning (use/height) + structural code + permit, and a single retrieval is never enough. - C) Agentic RAG only works with documents in English. - Answer: **B** — Classic RAG searches once and answers. The agentic version reasons about the sufficiency of what it retrieved and reformulates or crosses sources until it has full support. The anti-hallucination rule is programmed into the system prompt: if no fragment answers, the agent abstains ('not in the corpus') instead of inventing. 5. When evaluating whether the Regulatory Consultant ships to production, what does the 'abstention rate' measure and why is it critical? - A) The percentage of queries the model takes more than 5 seconds to answer. - B) The proportion of trap questions (about nonexistent rules) where the system correctly says "I couldn't find that rule" instead of inventing a convincing but false answer. - C) The number of tokens the system saves by not answering certain questions. - Answer: **B** — A regulatory consultant that can't say 'I don't know' is a legal liability: it will invent articles with total fluency. The evaluation feeds the system questions about nonexistent rules; together with groundedness (does every claim have a cited chunk?), abstention determines whether the system is fit for regulatory matters. ## Where it fits in the sector roadmap - Axis: AI Development + AI Collaboration - Dimensions: D4 · Data Quality, D5 · Data Governance - Use group: G1 · Site analysis & feasibility, G2 · Permits & regulatory compliance (Strategic enablers) - 52% of Colombian construction companies name lack of structured data as their top AI-adoption barrier (the most cited in the sector diagnostic). The RAG pipeline with verifiable citations you build here is the direct technical answer to D4 and D5: the Roadmap's international case for G2, UpCodes, cut plan-review corrections by 66% using exactly this pattern. ## Related - [Ask your specifications and contract questions, with citations](https://aibuilderacademy.netlify.app/prompts/spec-contract-qa.md) (prompt) - [Which MCP should I connect? Start from your data, not the tool](https://aibuilderacademy.netlify.app/prompts/which-mcp-to-connect.md) (prompt) --- AI Builder Academy · https://aibuilderacademy.netlify.app · checked 2026-09-30 · Made by Lo que habitas (Julián Páez). Agents: search more at https://aibuilderacademy.netlify.app/api/search?q=… or connect https://aibuilderacademy.netlify.app/mcp. Request a new prompt: aibuilderacademy@agentmail.to.