Dominando a engenharia RAG2 / 10
Chunking — The Decision That Sets Your Ceiling
You can't retrieve what you chunked badly. Chunking is the most under-rated lever in RAG — and the cheapest to get right.

Retrieval can only return the chunks you created. If a chunk splits an idea in half, no embedding model on earth will retrieve it whole. Chunking sets the ceiling on everything downstream.
Three strategies
- Fixed-size — split every N tokens with overlap. Simple, fast, dumb. Fine for uniform prose, bad for structured docs.
- Structural — split on the document's own boundaries: headings, sections, list items, code blocks. Respects meaning for free.
- Semantic — split where the topic shifts (embedding-distance based). Best quality, higher cost.
Start structural; it captures most of the win at near-zero cost.
Size and overlap
Too small and a chunk loses context; too big and retrieval gets noisy and the prompt gets expensive. A pragmatic default: 300–600 tokens with ~15% overlap, then tune against your eval set (article 7).
Metadata is the quiet superpower
Attach metadata to every chunk: source, title, section, date, URL. It powers filtered retrieval (only this product, only docs after this date) and lets the generator cite precisely.
Next: turning these chunks into vectors, and where to store them.
Série — Dominando a engenharia RAG
- Parte 01Por que RAG Ingênuo Falha em ProduçãoA demo de busca vetorial de 50 linhas que impressiona no notebook desmorona no momento em que usuários reais fazem perguntas reais. Aqui está o porquê — e o mapa de saída.
- Parte 02Chunking — The Decision That Sets Your Ceiling — você está aquiYou can't retrieve what you chunked badly. Chunking is the most under-rated lever in RAG — and the cheapest to get right.
- Parte 03Embeddings & Vector Stores 101Um embedding transforma significado em geometria. Uma vector store torna essa geometria pesquisável em milissegundos. Acerte ambos e a recuperação fica fácil.
- Parte 04Hybrid Retrieval — Keyword + VectorVector search compreende significado mas tropeça em termos exatos, IDs e palavras raras. Keyword search acerta nesses e erra em paráfrase. Use ambos.
- Parte 05Re-Ranking — The Cheap Quality WinRetrieval gets you 30 plausible chunks. A re-ranker reads them against the actual question and floats the truly relevant few to the top.
- Parte 06Prompting the Generator — Grounding & CitationsGreat retrieval is wasted if the model ignores it or can't point to its sources. Grounding is a prompt-design discipline, not an afterthought.
- Parte 07Avaliação — Você Não Pode Melhorar o Que Não MedeSem um conjunto de avaliação, toda mudança em RAG é uma intuição. Com um, você afina chunking, retrieval e prompts com um número que diz se ajudou ou prejudicou.
- Parte 08Tratando Alucinações e GuardrailsQuando a recuperação vem vazia, um modelo prestativo inventa. Guardrails transformam 'confiantemente errado' em 'honestamente incerto' — a diferença que os usuários realmente confiam.
- Parte 09Disciplina de Custo e LatênciaUma consulta RAG toca embeddings, um vector DB, um re-ranker e um LLM. Cada um adiciona milissegundos e centavos. Em escala, disciplina aqui é a diferença entre uma margem e um incêndio.
- Parte 10The Production RAG Reference ArchitectureEvery piece, assembled: ingestion, hybrid retrieval, re-ranking, grounded generation, guardrails, eval and caching — the blueprint you can ship.