Dominando a engenharia RAG5 / 10
Re-Ranking — The Cheap Quality Win
Retrieval gets you 30 plausible chunks. A re-ranker reads them against the actual question and floats the truly relevant few to the top.

Embedding search is fast but shallow: it compares your question and each chunk separately, then measures distance. A re-ranker is slow but deep: it reads the question and a chunk together and scores true relevance.
The pattern: retrieve wide, re-rank narrow
- Retrieve broadly — top 30–50 chunks via hybrid search (recall-optimized; cast a wide net).
- Re-rank those with a cross-encoder against the question.
- Keep the top 3–8 for the prompt (precision-optimized).
You get the recall of wide retrieval and the precision of deep scoring, without re-ranking your whole corpus.
Why it works
A bi-encoder (embeddings) must encode a chunk before it knows your question. A cross-encoder sees both at once, so it catches relevance that distance misses — negation, specificity, "this chunk is about X but doesn't answer X."
The trade-off
Re-ranking adds latency and cost per query (you score 30–50 pairs). Tune the retrieve-width and keep-count against your eval set and latency budget — covered in articles 7 and 9.
Now the retrieval is sharp. Next: making the generator actually use it — grounding and citations.
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 CeilingYou 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 Win — você está aquiRetrieval 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.